Hi,
The sample code i used was
class AssertDemo {
static int val = 3 ;
static int getNum() {
return val-- ;
}
public static void main(
String[] aa) {
int i = 0 ;
for(int j = 0; j<10; j++)
{
i = getNum() ;
assert n>0 ;
System.out.println("n is = " + n) ;
}
}
}
Am not able to compile the code at all, the javac compiler is not able to recognise the keyword assert, i got this error
C:\uma\java>javac AssertDemo.java
AssertDemo.java:17: ';' expected
assert n>0 ;
^
AssertDemo.java:17: cannot resolve symbol
symbol : class assert
location: class AssertDemo
assert n>0 ;
^
2 errors
hence i tried reading the usage from the sun site and tried using "javac -source 1.4" but, the option source was not recognized and is not listed when i tried using...
C:\uma\java>javac -source 1.4 AssertDemo.java
javac: invalid flag: -source
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-O Optimize; may hinder debugging or enlarge class file
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-target <release> Generate class files for specific VM version
java version "1.4.0_03" was used...
How do i resolve this?
Thanks,
Uma..