| Author |
doubt in assert...
|
Ganeshkumar cheekati
Ranch Hand
Joined: Oct 13, 2008
Posts: 362
|
|
assert can be used as an identifier in java1.3 and lower versions. but it is not allowed to use it higher of java1.4 versions because it is a keyword. when i am compiling above code using java1.3 javac -source 1.3 AssertTest1.java it is giving compilation error as AssertTest.java:6: warning: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier (use -source 1.4 or higher to use 'assert' as a keyword) int assert; ^ why?  [ November 06, 2008: Message edited by: Ganeshkumar cheekati ]
|
SCJP5 and SCWCD1.5
Think Twice Act Wise...
|
 |
Jayachandran Natarajan
Greenhorn
Joined: Nov 06, 2008
Posts: 1
|
|
Hi Ganesh, It looks like a warning, not an Error.. Regards Jay [ November 06, 2008: Message edited by: Jay ]
|
 |
Ganeshkumar cheekati
Ranch Hand
Joined: Oct 13, 2008
Posts: 362
|
|
what should we do to remove this warning ? [ November 06, 2008: Message edited by: Ganeshkumar cheekati ]
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
well you are using a 1.4 compiler or higher. That compiler knows that assert is now a keyword. So when you use -source 1.3, it warns you (not gives error) that assert is now a keyword. If you use actual 1.3 or older compiler, you will get no warnings. To remove this warning you will have to change the name of the variable in main method (however than the question will be of no use)...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Ganeshkumar cheekati
Ranch Hand
Joined: Oct 13, 2008
Posts: 362
|
|
eventhough i am using javac -source 1.3 AssertTest1.java it is giving warning at compile time and finally i got output at runtime.
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
eventhough i am using javac -source 1.3 AssertTest1.java it is giving warning at compile time and finally i got output at runtime
Warnings are not Errors. They are like well, Warnings !!! Just to keep you informed about some important things compiler won't held responsible?
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
|
Jay, welcome to JavaRanch. Please check your private messages. You can see them by clicking My Private Messages.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
krishna pr
Greenhorn
Joined: Oct 28, 2008
Posts: 8
|
|
|
Try Giving Java -version
|
 |
 |
|
|
subject: doubt in assert...
|
|
|