mrs nair wrote:hi there ,
i was wondering what the output should be for the following code ,
public static void main(String[] args) {
// TODO Auto-generated method stub
int age =18;
assert(age < 18);
System.out.println("hello here......................");
}
surely an assertion error and the "hello here" shouldn't be displayed ..i am sorry but this dosent happen when i run it on eclipse indigo and i use jdk 1.6.0_27.can anyone figure out where's the bug?
Hello Mrs Nair... Assertions are disabled by default, if you intend to enable assertions in other for the above code to throw an assertion error, you can simply use the command lines and navigate to the .class file
or the packge directory and run the class with the -ea (enable assertions) flag, i.e '
java -ea com.xxx.YourClass'...
HTH
Ikpefua