Hi everybody, I got a problem with sdk 1.5; in my data structures book it says we can use (sdk 1.5) collections in a generic way such as:
LinkedList<Integer> intList = new LinkedList<Integer>();
I work with eclipse 3.0 and have sdk 1.5 beta installed, but when I type the code above, I'm not able to compile. the error msg is "syntax error on token "<" invalid AssignmentOperator" Am I missing something obvious here? Any help is greatly appreciated!
Thanks Jeroen, in this case it should work when i use command line to compile and execute my files, but somehow it gives me the same error message when i try to compile it via cmd. any more ideas?? help is greatly appreciated.
It was the same way for Java 1.4. Since there's code which is legal only with -source 1.3 and code which is legal only with -source 1.4 the people at Sun decided not to break legacy build configurations by causing the default setting to break on older code. It's easier for developers to simply adopt new habits with new versions and let old versions continue to function unaware of the differences. If it weren't for the new keywords (assert in 1.4, enum + foreach and whatever else in 1.5) this wouldn't be a problem, but alas it is.
the new keywords (assert in 1.4, enum + foreach and whatever else in 1.5)
It's just enum for 1.5. There's no foreach keyword - there's just a new syntax using "for". Still, enum is enough reason for them to be careful about backwards compatibility, since I've seen people write things like