Received warnings from javac -Xlint: unverified

I have 2 warnings after trying to use the -Xlint switch. How can I resolve these warnings?

test:quadrantRDBTemplate mymac$ javac -Xlint:unchecked -cp mysql-connector-java-5.0.jar:iucbrf.jar *.java 
QuadrantSystemRDB.java:271: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.HashMap
    argMap.put(xKey, new UniformDistribution(-1, 1));
              ^
QuadrantSystemRDB.java:272: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.HashMap
    argMap.put(yKey, new UniformDistribution(-1, 1));
              ^
2 warnings
+5
source share
4 answers

A raw type is a type that can have a type argument, but is not included. For example, Map(u HashMap) may have type parameters Kand Vkey types and values respectively.

So, you can specify Map<Integer,String>to indicate that the map contains Integerobjects as keys and maps them to objects String.

Map, . , .

. Map. , V UniformDistribution, K yKey xKey.

+7

! , xKey - String, argMap :

Map<String, UniformDist> argMap = new HashMap<String, UniformDist>()
+4

generics argMap. , QuadrantSystemRDB - . , - :)

+1

, , List, (,), '<' ' > ':

List<Integer> list = new ArrayList();

I tried declaring an object on the stack without NetBeans, and NetBeans compiled my code without error messages. Perhaps with the javac compiler everything is different.

+1
source

All Articles