warning: [unchecked] unchecked cast found
843810Feb 5 2010 — edited Feb 5 2010I am getting the following warning when I compile my code. Please help.
warning: [unchecked] unchecked cast
found : java.lang.Object
required: java.util.Vector<java.lang.Long>
copy.path = (Vector<Long>) this.path.clone();
1 warning
Here is the code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cs572project1;
import java.util.*;
/*
* Richard Becraft
* 1/22/2010
* CS 572 Heuristic Problem Solving
*
* This class represents a node in a search tree of a graph that represents a street map.
*/
public class SearchNode implements Cloneable {
public long depth;
public double costSoFar;
public double estimatedCostToGoal;
public Vector<Long> path;
public SearchNode() {
depth = -1;
costSoFar = -1;
estimatedCostToGoal = -1;
path = new Vector<Long>(20, 20);
}
public void printSearchNode() {
System.out.println("\n****In printSearchNode");
System.out.println("depth: " + depth + " costSoFar: " + costSoFar + " estimatedCostToGoal: " + estimatedCostToGoal);
for (Enumeration<Long> e = this.path.elements(); e.hasMoreElements();) {
System.out.println(e.nextElement());
}
System.out.println("****Exiting printSearchNode\n");
}
@Override
public SearchNode clone() {
SearchNode copy;
try {
//System.out.println("in clone SearchNode");
copy = (SearchNode) super.clone();
copy.path = (Vector<Long>) this.path.clone(); // <<<< the offending line
//copy.path = new Vector<Long>(this.path.capacity());
//this.printSearchNode();
//System.out.println("copy.path.size: " + copy.path.size());
//System.out.println("this.path.size: " + this.path.size());
//System.out.println("copy.path.capacity: " + copy.path.capacity());
//System.out.println("this.path.capacity: " + this.path.capacity());
//Collections.copy(copy.path, this.path);
} catch (CloneNotSupportedException e) {
throw new RuntimeException("This class does not implement Cloneable " + e);
}
return copy;
}
}