new Datetime();错误?

pody 2010-10-10 02:57:47
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;


public class No17 {

public class Datetime{

private Date today;
private SimpleDateFormat sdf;

Datetime(){
today =new Date();
sdf=new SimpleDateFormat("EEEE MMMM dd,yyyy");
}

public void showtime(){
JOptionPane.showMessageDialog(null, sdf.format(today));
}
}

public static void main(String[] args) {
Datetime today=new Datetime();
today.showtime();
}
}



显示错误:
java.lang.Error: Unresolved compilation problem:
Must explicitly qualify the allocation with an enclosing instance of type chapter2.No17 (e.g. x.new A() where x is an instance of chapter2.No17).

at java.lang.reflect.Constructor.newInstance(Native Method)
at chapter2.No17.main(No17.java:26)
Exception in thread "main"
...全文
90 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
pody 2010-10-10
Datetime today=new Datetime();为什么会错误呢?如何修改?
回复
相关推荐
发帖
J2ME
创建于2007-09-28

1.3w+

社区成员

Java J2ME
申请成为版主
帖子事件
创建了帖子
2010-10-10 02:57
社区公告
暂无公告