Do I need to import any particular package for assertions to work. I am using JBuilder 7 and it is uisng JDk1.4.0 and it just doesn't recognize the word assert.
Chiran Mathur
Ranch Hand
Joined: Feb 07, 2001
Posts: 63
posted
0
package assertUse; import java.util.*; import java.io.*; import java.lang.Error.*; public class AssertTest{ public void methodA(int i) throws AssertionError{ assert i < 1024 : "Invalid Value"; } } I always get this error while compilingthe above code: "assertUse.java": Error #: 200 : ';' expected at line 7, column 18
Sridhar Srikanthan
Ranch Hand
Joined: Jan 08, 2003
Posts: 366
posted
0
Chiran, one possible problem might be the way you are compiling the code. In order for the code with assertions to be compiled, you have to type javac -source 1.4 AssertTest.java I tried the same code and it compiles just fine Hope this helps Sri
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Cannot get code with assertions to compile