Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token ":", * expected
public class TestAssert { public void methodA(int i){
assert (i>=0 : methodB());
System.out.pritnln(i);
}
public int methodB(){
System.out.println("The value must not be negative");
return 3;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
TestAssert test=new TestAssert();
test.methodA(-10);
}}
Syntax error on token ":", * expected
public class TestAssert { public void methodA(int i){
assert (i>=0 : methodB());
System.out.pritnln(i);
}
public int methodB(){
System.out.println("The value must not be negative");
return 3;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
TestAssert test=new TestAssert();
test.methodA(-10);
}}
assert (i>=0 : methodB());
错了,
应该是 assert (i>=0) : methodB();
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "assert", ( expected
Syntax error, insert ";" to complete BlockStatements
Syntax error, insert "AssignmentOperator ArrayInitializer" to complete ArrayInitializerAssignement
Syntax error, insert ")" to complete Expression调试看看