当前位置: 技术问答>java相关
请大家帮忙看看这个错误。。。谢谢拉。。。
来源: 互联网 发布时间:2015-02-18
本文导语: package my.tools.debug; public class Assert { private static void perr(String msg) { System.err.println(msg); } public final static void is_true(boolean exp) { if(!exp) perr("Assertion failed"); } public final static void is_fa...
package my.tools.debug;
public class Assert {
private static void perr(String msg) {
System.err.println(msg);
}
public final static void is_true(boolean exp) {
if(!exp) perr("Assertion failed");
}
public final static void is_false(boolean exp){
if(exp) perr("Assertion failed");
}
public final static void
is_true(boolean exp, String msg) {
if(!exp) perr("Assertion failed: " + msg);
}
public final static void
is_false(boolean exp, String msg) {
if(exp) perr("Assertion failed: " + msg);
}
} ///:~
我在编译上面这段程序时出现错误:
declared in a file named Assert.java
public class Assert {
^
1 error
当我把public class Assert改为class Assert就编译成功了,不是说开头的类都要是public,为什么我编译不了呢?
public class Assert {
private static void perr(String msg) {
System.err.println(msg);
}
public final static void is_true(boolean exp) {
if(!exp) perr("Assertion failed");
}
public final static void is_false(boolean exp){
if(exp) perr("Assertion failed");
}
public final static void
is_true(boolean exp, String msg) {
if(!exp) perr("Assertion failed: " + msg);
}
public final static void
is_false(boolean exp, String msg) {
if(exp) perr("Assertion failed: " + msg);
}
} ///:~
我在编译上面这段程序时出现错误:
declared in a file named Assert.java
public class Assert {
^
1 error
当我把public class Assert改为class Assert就编译成功了,不是说开头的类都要是public,为什么我编译不了呢?
|
不是说得很清楚吗?
declared in a file named Assert.java
public的泪所在的文件一定要以类名命名
declared in a file named Assert.java
public的泪所在的文件一定要以类名命名
|
你的文件名必须用Assert.java