Unchecked cast means that you are casting from a generic type to a non-qualified type, or the other way around.
Questions tagged [unchecked-cast]
51 questions
0
votes
0 answers
Unchecked cast from Class
I have this code:
public DriverExtensionFactory(
Class extends AbstractNetworkInterface> serviceClass) {
super((Class) serviceClass);
}
And it tells me that
Type safety: Unchecked cast from…

PedroD
- 5,670
- 12
- 46
- 84
0
votes
4 answers
Java: Returning an extended class given it's name
In the following code I am returning a class that extends the type of Entity given the name of the class (it then corrects it so that Class.forName can find it properly).
How can I modify this so that I can still return a class that extends Entity…

Nahydrin
- 13,197
- 12
- 59
- 101
0
votes
2 answers
Warning: [unchecked] unchecked cast. Generics
I am encountering warnings of unchecked cast. I'm not sure how to resolve the warnings.
The compiler error seems to pick on list = (E[]) new IntKeyed [size];
Which is the code we are suppose to used letter for letter.
We are attempting to use…

iYeti
- 1
- 1
- 3
-1
votes
1 answer
Why Variable-Parameterized variant of (cast) operator in Java is flagged as unchecked warning and not error?
Consider the following snippet:
class MyClass{
...
public void checkType(Object o){
if(o instanceof List){ //this gives compilation error
List list = (List)o; //this gives unchecked warning
}
}
...
}
Here, the instanceof will give…

theutonium.18
- 483
- 2
- 7
-1
votes
2 answers
Avoiding making classes generic by using unchecked type casts
Let's say I create a package process with a public class Processor, which has a constructor that expects a parameter of type Container. The class Container lies in a different package beyond my control and contains objects of arbitrary type I.…

Calculator
- 2,769
- 1
- 13
- 18
-1
votes
1 answer
Why "Unchecked cast from..."
I don't understand why I get an Unchecked cast from Object to Compareable

7heViking
- 7,137
- 11
- 50
- 94