标题:[求助]'class' or 'interface' expected
只看楼主
kingyor
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2006-6-4
 问题点数:0 回复次数:12 
[求助]'class' or 'interface' expected
D:\java\dates\jspcalendar.java:1: 'class' or 'interface' expected
packege dates;
^
D:\java\dates\jspcalendar.java:2: 'class' or 'interface' expected
import java.text.DateFormat;
^
D:\java\dates\jspcalendar.java:3: 'class' or 'interface' expected
import java.util.*;
^
3 errors



//下面的源程序
packege dates;
import java.text.DateFormat;
import java.util.*;
public class jspcalendar{
Calendar calendar = null;
public jspcalendar(){
calendar = Calendar.getInstance();
Date trialTime = new Date();
canlendar.setTime(trialTime);
}
//duqu year
public int getYear(){
return calendar.get(Calendar.YEAR);
}
//duqu month
public String getMonth(){
int m = getMonthInt();
String[] months = new String[]{"January","February","march",
"April","May","June","July","August","September",
"October","November","december"};
if (m>12)
return "Unknown to man";
return months[m-1];
}
//du weekday
public String getDay(){
int x = getDayOfWeek();
String[] days=new String[] {"Sunday","Monday","Tuesday","wednesday","Thursday",
"Friday","Saturday"};
if (x>7)
return "Unkown to man";
return days[x-1];
}
//duqu mnoth/day/year
public String getDate(){
return getMonthInt() + ":" + getDayOfWeek() + "/" +getYear();
}
//duqu huor/minute/second
public String getTime(){
return getHour() + ":" = getMinute() + ":" + getSecond();
}
public int getDayOfMonth(){
return calendar.get(Calendar.DAY_OF_MONTH);
}
public int getDayOfYear(){
return calendar.get(Calendar.DAY_OF_YEAR);
}
public int getWeekOfYear(){
return calendar.get(Calendar.WEEK_OF_YEAR);
}
public int getWeekOfMonth(){
return calendar.get(Calendar.WEEK_OF_MONTH);
}
public int getDayOfWeek(){
return calendar.get(Calendar.DAY_OF_WEEK);
}
public int getHour(){
return calendar.get(Calendar.HOUR_OF_DAY);
}
public int getMinute(){
return calendar.get(Calendar.MINUTE);
}
public int getSecond(){
return calendar.get(Calendar.SECOND);
}
public static void main(String args[]){
jspcalendar db = new jsapcalendar();
p("date:"+db.getDayOfMonth());
p("year:"+db.getYear());
p("month:"+db.getMonth());
p("time:"+db.getTime());
p("date:"+db.getDate());
p("Day:"+db.getDay());
p("Dayofyear:"+db.getDayOfYear());
p("Weekofyear:"+db.getWeekOfYear());
p("era:"+db.getEra());
p("ampm:"+db.getAMPM());
p("Dst:"+db.getDSTOffset());
p("Zone offset:"+db.getZoneOffset());
p("timezone:"+db.getUSTimeZone());
}
public static void p(String x){
System.out.println(x);
}
public int getEra(){
return calendar.get(Calendar.ERA);
}
public String getUSTimeZone(){
String zones = new String[]{"hawaii","Alaskan","pacific","Mountain","Central","Eastern"};
return zones[10+getZoneOffset()];
}
public int getZoneOffset(){
return calendar.get(Calendar.ZONE_OFFSET)/(60*60*10000);
}
public int getDSTOffset(){
return calendar.get(Calendar.DST_OFFSET)/(60*60*10000);
}
public int getAMPM(){
return calendar.get(Calendar.AM_PM);
}
}
搜索更多相关主题的帖子: interface expected class 
2006-12-11 15:38
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
得分:0 
你是不是classpath之类的变量都没设啊!!

开开心心的过&玩每一天!!!!
2006-12-11 16:16
神经塔
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1986
专家分:4
注 册:2006-7-1
得分:0 
package dates

[shadow=255,red,2]待到秋来九月八,我花开时百花杀。冲天香阵透长安,满城尽是黄金甲。 [/shadow]
2006-12-11 17:48
一二三四五
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:856
专家分:0
注 册:2006-11-13
得分:0 

关键字都会打错


hey,di va la
2006-12-11 17:52
しΟν∈→鱈
Rank: 1
等 级:新手上路
威 望:2
帖 子:369
专家分:0
注 册:2006-10-25
得分:0 
还以为找不到路径呢

开开心心的过&玩每一天!!!!
2006-12-11 18:56
kingyor
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2006-6-4
得分:0 

汗~~谢谢各位提醒,不过该了之后编译还是有好多错误,最后还剩下两个不知道怎么解决,请各位指点一下~~~汗~~~

主要的那个int m = getMonthInt();

//编译时报错信息
D:\java\dates\jspcalendar.java:17: cannot resolve symbol
symbol : method getMonthInt ()
location: class dates.jspcalendar
int m = getMonthInt();
^
D:\java\dates\jspcalendar.java:36: cannot resolve symbol
symbol : method getMonthInt ()
location: class dates.jspcalendar
return getMonthInt() + ":" + getDayOfWeek() + "/" +getYear();
^
2 errors

//改后程序
package dates;
import java.text.DateFormat;
import java.util.*;
public class jspcalendar{
Calendar calendar = null;
public jspcalendar(){
calendar = Calendar.getInstance();
Date trialTime = new Date();
calendar.setTime(trialTime);
}
//duqu year
public int getYear(){
return calendar.get(Calendar.YEAR);
}
//duqu month
public String getMonth(){
int m = getMonthInt();
String[] months = new String[]{"January","February","march",
"April","May","June","July","August","September",
"October","November","december"};
if (m>12)
return "Unknown to man";
return months[m-1];
}
//du weekday
public String getDay(){
int x = getDayOfWeek();
String[] days=new String[] {"Sunday","Monday","Tuesday","wednesday","Thursday",
"Friday","Saturday"};
if (x>7)
return "Unkown to man";
return days[x-1];
}
//duqu mnoth/day/year
public String getDate(){
return getMonthInt() + ":" + getDayOfWeek() + "/" +getYear();
}
//duqu huor/minute/second
public String getTime(){
return getHour() + ":" + getMinute() + ":" + getSecond();
}
public int getDayOfMonth(){
return calendar.get(Calendar.DAY_OF_MONTH);
}
public int getDayOfYear(){
return calendar.get(Calendar.DAY_OF_YEAR);
}
public int getWeekOfYear(){
return calendar.get(Calendar.WEEK_OF_YEAR);
}
public int getWeekOfMonth(){
return calendar.get(Calendar.WEEK_OF_MONTH);
}
public int getDayOfWeek(){
return calendar.get(Calendar.DAY_OF_WEEK);
}
public int getHour(){
return calendar.get(Calendar.HOUR_OF_DAY);
}
public int getMinute(){
return calendar.get(Calendar.MINUTE);
}
public int getSecond(){
return calendar.get(Calendar.SECOND);
}
public static void main(String args[]){
jspcalendar db = new jspcalendar();
p("date:"+db.getDayOfMonth());
p("year:"+db.getYear());
p("month:"+db.getMonth());
p("time:"+db.getTime());
p("date:"+db.getDate());
p("Day:"+db.getDay());
p("Dayofyear:"+db.getDayOfYear());
p("Weekofyear:"+db.getWeekOfYear());
p("era:"+db.getEra());
p("ampm:"+db.getAMPM());
p("Dst:"+db.getDSTOffset());
p("Zone offset:"+db.getZoneOffset());
p("timezone:"+db.getUSTimeZone());
}
public static void p(String x){
System.out.println(x);
}
public int getEra(){
return calendar.get(Calendar.ERA);
}
public String getUSTimeZone(){
String[] zones = new String[] {"hawaii","Alaskan","pacific","Mountain","Central","Eastern"};
return zones[10+getZoneOffset()];
}
public int getZoneOffset(){
return calendar.get(Calendar.ZONE_OFFSET)/(60*60*10000);
}
public int getDSTOffset(){
return calendar.get(Calendar.DST_OFFSET)/(60*60*10000);
}
public int getAMPM(){
return calendar.get(Calendar.AM_PM);
}
}


宝哥啊宝哥~~命苦啊命苦啊~~~
2006-12-12 21:06
yqfang310
Rank: 2
等 级:新手上路
威 望:4
帖 子:458
专家分:0
注 册:2006-10-10
得分:0 

Date里面本来就有这个函数getMonth()它返回的是一个整形,不知道你用这个getMonthInt()是啥意思


JAVA是什么?我也不清楚......
2006-12-12 21:12
一二三四五
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:856
专家分:0
注 册:2006-11-13
得分:0 

编译器告诉得很清楚了
method getMonthInt ()
这个方法你没有定义,怎么调用


hey,di va la
2006-12-12 21:31
一二三四五
Rank: 3Rank: 3
等 级:新手上路
威 望:8
帖 子:856
专家分:0
注 册:2006-11-13
得分:0 

编译器告诉得很清楚了
method getMonthInt ()
这个方法你没有定义,怎么调用


hey,di va la
2006-12-12 21:31
kingyor
Rank: 1
等 级:新手上路
帖 子:66
专家分:0
注 册:2006-6-4
得分:0 

呢我是想把那个整形给m,让getmonth()返回months[m-1]的值.


宝哥啊宝哥~~命苦啊命苦啊~~~
2006-12-15 09:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-108806-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.393943 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved