javac -Xlint TestTwelve.java
TestTwelve.java:21: warning: [unchecked] unchecked call to add(E) as a member of
the raw type java.util.Vector
"This is the consequence of a somewhat unfortunate limitation of generic types in Java.
For compatibility, the compiler translates all typed array lists into raw ArrayList objects
after checking that the type rules were not violated. In a running program, all array lists
are the same—there are no type parameters in the virtual machine. Thus, the casts
(ArrayList) and (ArrayList<Employee>) carry out identical runtime checks.
There isn’t much you can do about that situation. When you interact with legacy code,
study the compiler warnings and satisfy yourself that the warnings are not serious. "
Core Java Volume 1 (8th Edition) Pg. 211
Chess symbols article at http://en.wikipedia.org/wiki/Chess_symbols_in_Unicode.
Code sourced from an article.
Matthew Brown wrote:Yes. What's the question?
You should always use generic types, unless you really have no choice. Change Vector to Vector<String> (or whatever type Font.getFontName() returns) and the warning (warning, not error) will go away.
It works as follows:
Now I'm just wondering how to read the String myChessPiece, because it will return '?' to the console, so I'm wondering whether there is a problem with the language environment.
NOTE: The copy to clipboard function on this forum does not work in my environment (Google Chrome/WinXP SP3).