assert is a keyword introduce at jdk 1.4,You cannot use it as an identifier in jdk1.4 +.
However if you have used it as an identifier,and you want to compile the class,then you need to go back to jdk 1.3.
But you have only jdk 1.6 with you.Still then you can compile your java class,as if you are using jdk 1.3
Demo.java
compile using jdk 1.4+ will give you these error
-------------------------------------------------
>javac Demo.java
Demo.java:5: as of release 1.4, 'assert' is a keyword, and may not be used as an
identifier
(use -source 1.3 or lower to use 'assert' as an identifier)
boolean assert = true;
^
Demo.java:6: as of release 1.4, 'assert' is a keyword, and may not be used as an
identifier
(use -source 1.3 or lower to use 'assert' as an identifier)
if(assert) System.out.println("if is true");
To compile as jdk1.3 although you are using jdk 1.4+
--------------------------------------------------------
>javac -source 1.3 Demo.java
However if you have used it as an identifier,and you want to compile the class,then you need to go back to jdk 1.3.
But you have only jdk 1.6 with you.Still then you can compile your java class,as if you are using jdk 1.3
Demo.java
public class Demo
{
public static void main(String[] args)
{
boolean assert = true;
if(assert) System.out.println("if is true");
}
}
compile using jdk 1.4+ will give you these error
-------------------------------------------------
>javac Demo.java
Demo.java:5: as of release 1.4, 'assert' is a keyword, and may not be used as an
identifier
(use -source 1.3 or lower to use 'assert' as an identifier)
boolean assert = true;
^
Demo.java:6: as of release 1.4, 'assert' is a keyword, and may not be used as an
identifier
(use -source 1.3 or lower to use 'assert' as an identifier)
if(assert) System.out.println("if is true");
To compile as jdk1.3 although you are using jdk 1.4+
--------------------------------------------------------
>javac -source 1.3 Demo.java