I am compiling my code and I keep getting an unsafe or unchecked operations warning. I know it is just a warning, but I still need it to disappear without suppressing it. I've researched and it looks like it comes from ArrayList generalizations, but I don't know how to fix it. I've included the relevant portions of code.
//Variables at the top of class Vector[] adjacency; //Constructor adjacency = new Vector[N*N]; for(int i=0;i<adjacency.length;i++) adjacency[i] = new Vector<Integer>(); //In a called method - node & neighbor are both ints if(node<neighbor) adjacency[node].add(neighbor); else adjacency[neighbor].add(node); //In another called method - node & neighbor are both ints if(node<neighbor) if(!adjacency[node].contains(neighbor)) { //Add to graph and increase count adjacency[node].add(neighbor); count++; } if(neighbor<node) if(adjacency[neighbor].contains(node)) { //Add to graph and increase count adjacency[neighbor].add(node); count++; }
Here is the warning I get from the compiler when I ask for details (-Xlint:unchecked)
travis-mac:Project3 Travis$ javac TMMp3.java -Xlint:unchecked TMMp3.java:76: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector adjacency[node].add(neighbor); ^ TMMp3.java:78: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector adjacency[neighbor].add(node); ^ TMMp3.java:147: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector adjacency[node].add(neighbor); ^ TMMp3.java:153: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector adjacency[neighbor].add(node); ^ 4 warnings
If you can help me get this warning to go away that would be great!
Thanks,
Travis