I'm studying for the exam using the JAVA2 study guide by Kathy Sierra and Bert Bates. Their book says that compiler will comile code with assert statements as if you were running 1.3 unless you specify version 1.4 explicitly. My compiler does not compile at all unless I specify which version I want to use. It probably is not that important, but I would like to know if this is JVM specific, and there are compilers that default to 1.3 when there are assert statements in the code. Thanks.
Mariya, Which JVM are you running? I am studying for the same exam, using the same book, and when I went through the assert lesson in the book, it worked just as explained: javac -source 1.4 Pgmname.java (enable use of java assert keyword) javac -source 1.3 Pgmname.java (allow user defined assert variable) java -ea Pgmname (enable java assert) -Thomas
Joined: Nov 10, 2003
oops ... forgot to mention I'm using Suns j2sdk1.4.2_03, on a MS XP OS.
Joined: Feb 04, 2004
Yes, I know, but if I compile: javac Pgmname.java without specifying version, and I use assert statements in my code I get a compiler error. The book said if you don't specify version compiler will default to 1.3. Please try and let me know. May be I misread. Thanks.