当前位置: 技术问答>java相关
jcreator pro 2.5,jdk1.4rc,这个接口怎么编译不了?
来源: 互联网 发布时间:2015-08-02
本文导语: 里的例子 ------const.java----------- import java.awt.*; public interface const { int LINE = 101; int RECTANGLE = 102; int CIRCLE = 103; int CURVE = 104; int DEFAULT_ELEMENT_TYPE = LINE; Color DEFAULT_ELEMENT_COLOR = Color.blue; } --------------------Sk...
里的例子
------const.java-----------
import java.awt.*;
public interface const
{
int LINE = 101;
int RECTANGLE = 102;
int CIRCLE = 103;
int CURVE = 104;
int DEFAULT_ELEMENT_TYPE = LINE;
Color DEFAULT_ELEMENT_COLOR = Color.blue;
}
--------------------SketchFrame.java-----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SketchFrame extends JFrame implements const
{
.........................
在同一个project中,编译时出错,摘录如下
D:programJCreator ProMyProjectsSketcherSketcherconst.java:3: expected
public interface const
^
D:programJCreator ProMyProjectsSketcherSketcherconst.java:11: '{' expected
}
^
D:programJCreator ProMyProjectsSketcherSketcherSketchFrame.java:5: illegal start of type
public class SketchFrame extends JFrame implements const
如果单独编译const.java的话,也出错
D:programJCreator ProMyProjectsSketcherSketcherconst.java:3: expected
public interface const
^
D:programJCreator ProMyProjectsSketcherSketcherconst.java:11: '{' expected
}
^
D:programJCreator ProMyProjectsSketcherSketcherconst.java:3: class is public, should be declared in a file named .java
public interface const
这几个错误提示我看的莫名其妙,尤其是"class is public, should be declared in a file named .java public interface const",文件名的确是const.java,接口名也是const,怎么错了呢?
请高手指点,谢谢!
------const.java-----------
import java.awt.*;
public interface const
{
int LINE = 101;
int RECTANGLE = 102;
int CIRCLE = 103;
int CURVE = 104;
int DEFAULT_ELEMENT_TYPE = LINE;
Color DEFAULT_ELEMENT_COLOR = Color.blue;
}
--------------------SketchFrame.java-----------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SketchFrame extends JFrame implements const
{
.........................
在同一个project中,编译时出错,摘录如下
D:programJCreator ProMyProjectsSketcherSketcherconst.java:3: expected
public interface const
^
D:programJCreator ProMyProjectsSketcherSketcherconst.java:11: '{' expected
}
^
D:programJCreator ProMyProjectsSketcherSketcherSketchFrame.java:5: illegal start of type
public class SketchFrame extends JFrame implements const
如果单独编译const.java的话,也出错
D:programJCreator ProMyProjectsSketcherSketcherconst.java:3: expected
public interface const
^
D:programJCreator ProMyProjectsSketcherSketcherconst.java:11: '{' expected
}
^
D:programJCreator ProMyProjectsSketcherSketcherconst.java:3: class is public, should be declared in a file named .java
public interface const
这几个错误提示我看的莫名其妙,尤其是"class is public, should be declared in a file named .java public interface const",文件名的确是const.java,接口名也是const,怎么错了呢?
请高手指点,谢谢!
|
兄弟,const是Java中保留的关键字!
|
同一个.JAVA文件里只能有一个PUBLIC 定义的CLASS或者INTERFACE,你的.JAVA文件里有两个了!!!