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"