D
Dan Upton
When trying to compile something I was working on today, I got this
error based on a performing a cast:
PuzzleSolver.java:311: warning: [unchecked] unchecked cast
found : java.lang.Object
required: java.util.Vector<Piece>
piecesClone = (Vector<Piece>)pieces.clone();
I know it's a safe cast, but just for the sake of getting javac to leave
me alone I tried sticking it in a try...catch block:
Vector<Piece> piecesClone=null;
try{
piecesClone = (Vector<Piece>)pieces.clone();
}catch(ClassCastException cce){
System.out.println("This is just so javac will shut up");
}
I still get the warning from the compiler though, so I'm assuming this
*isn't* the correct way to check a cast. Any tips on what *is* then?
error based on a performing a cast:
PuzzleSolver.java:311: warning: [unchecked] unchecked cast
found : java.lang.Object
required: java.util.Vector<Piece>
piecesClone = (Vector<Piece>)pieces.clone();
I know it's a safe cast, but just for the sake of getting javac to leave
me alone I tried sticking it in a try...catch block:
Vector<Piece> piecesClone=null;
try{
piecesClone = (Vector<Piece>)pieces.clone();
}catch(ClassCastException cce){
System.out.println("This is just so javac will shut up");
}
I still get the warning from the compiler though, so I'm assuming this
*isn't* the correct way to check a cast. Any tips on what *is* then?