Linked Questions
56 questions linked to/from How do I address unchecked cast warnings?
17 votes
3 answers
29k views
unchecked cast warning - how to avoid this? [duplicate]
I'm getting a "Type safety: Unchecked cast from Object to ArrayList" warning on the line with readObject(), in this code snippet: // Read the Event List theEventArrayList = new ArrayList<Event>(...
1 vote
1 answer
8k views
uses unchecked or unsafe operations, Recompile with -Xlint:unchecked for details [duplicate]
I have an application and when I try to run it shows an error : uses unchecked or unsafe operations. Recompile with -Xlint:unchecked for details. If anyone has an idea why How do I solve this ...
0 votes
2 answers
4k views
VetorTest.java uses unchecked and unsafe operation With -Xlint error [duplicate]
I am getting this error but don't know how to resolve it.I have already gone through the post but still confused. I tried to run Xlint File.java but its not working. While running this code, I am ...
2 votes
2 answers
1k views
Fix unchecked cast from Object to ComboBox<String> javafx [duplicate]
I have built a GUI with JavaFX/Scenebuilder which has multiple dropdowns with similar functions. I want to use the same function for all dropdowns so I have to check where the action event came from. ...
0 votes
0 answers
4k views
How to avoid "unchecked or unsafe operations" warning in case of generic method [duplicate]
I would like to avoid "unchecked or unsafe operations" message from java compiler, but I have no idea how to do it, when I have a generic method, and would like to return the values from a generic Map....
2 votes
3 answers
1k views
How to fix code to remove -Xlint:unchecked warning while compiling [duplicate]
Possible Duplicate: How do I address unchecked cast warnings? My program compiles and works correctly when I compile with -Xlint:unchecked, but I am looking for assistance to remove this warning. ...
0 votes
1 answer
380 views
How to fix Unchecked cast warning in generic type casting [duplicate]
I'm implementing a list link in the stack. The program successfully passes all the required tests, but I encounter this warning. There is no disruption in the implementation of the program, but I am ...
0 votes
0 answers
667 views
unchecked call to setModel(ListModel<E>) [duplicate]
In my application, in which I have two JLists, I'm trying to show the contents of the second one depending on what is selected in the first one. Let's say I have group 1, group 2 and group 3 at List1, ...
-1 votes
1 answer
153 views
Preventing instanceof and casting in Java [duplicate]
How do I avoid using instanceof and casting in this situation if I want to have different validators where the method signatures differ? Code for(BatchValidator validator : validators) { try { ...
0 votes
0 answers
318 views
Avoid unchecked compiler warning [duplicate]
I have this API which I can't change: public interface A<T> { void onClick(T widget); } public interface B<T> { void use(A<T> a); } public interface C { B<?> apply(); } ...
0 votes
1 answer
159 views
Java compiler warning caused by generics when saving ArrayLists [duplicate]
This seems like a pretty standard problem, but it's just so simple I don't know what to do about it. From what I've read elsewhere on SO, this is caused by Generics when ArrayLists are initialized ...
2 votes
1 answer
161 views
Detect if Object is a List<String> [duplicate]
I want to be sure if the object I get is a List of Strings. Here's my code: Object obj = plugin.getConfig().get("groups"); if(obj instanceof List<?>){ // Is the Object a List ? List<?>...
1 vote
0 answers
24 views
Casting superclass to Generic type T [duplicate]
I have recently started using generic methods in my projects. I am working on a chess project where every piece class extends to Pieces.java. Diagram of my pieces package And in the Player.java, I ...
337 votes
10 answers
565k views
Type safety: Unchecked cast
In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String" value-type="java....
94 votes
13 answers
160k views
What is the "proper" way to cast Hibernate Query.list() to List<Type>?
I'm a newbie with Hibernate, and I'm writing a simple method to return a list of objects matching a specific filter. List<Foo> seemed a natural return type. Whatever I do, I can't seem to make ...