Error javac -Xlint TestTwelve.java
TestTwelve.java:21: warning: [unchecked] unchecked call to add(E) as a member of
the raw type java.util.Vector chessFonts.add(allfonts[j].getFontName());
^
1 warning
"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. "
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.
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).
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: [error] unchecked call to add<E> as a member of the raw type of java.util.Vector