开发者

identifiers in java with different versions?

as we "No keyword should be used as an Identifier in java". But there will be some words like asser or enum or any other which have been add开发者_运维百科ed as keyword in version 1.4, 1.5 resp. So if any older version code is used to compile with new javac, what happens if that code contains these words as an identifier?


When older code uses an identifier that is a keyword in the current version you are trying to compile the code with, you will simply get an error. The compiler won't be able to tell from the code what version it was written for.


You'll get a compile error. But you can use already compiled classes if you aren't going to make changes in your legacy code.


Thanks for your answer, After searching i got to know the answer as, if any keyword is used as an identifier then we have to compile it with its compliant compiler otherwise it gives a compiler error. So to do that say suppose if my code has a assert as an identifier which works fine with java 1.3. So i can compile it as

javac -source 1.3 example.java

which compiles fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜