Linked Questions
56 questions linked to/from How do I address unchecked cast warnings?
91 votes
2 answers
78k views
How to send hashmap value to another activity using an intent
How to send HashMap value from one Intent to second Intent? Also, how to retrieve that HashMap value in the second Activity?
53 votes
7 answers
94k views
Type safety: Unchecked cast from Object
I try to cast an object to my Action class, but it results in a warning: Type safety: Unchecked cast from Object to Action<ClientInterface> Action<ClientInterface> action = null; try { ...
61 votes
4 answers
81k views
CXF JAXRS - How do I pass Date as QueryParam
I have a service defined as follows. public String getData(@QueryParam("date") Date date) I'm trying to pass a java.util.Date to it from my client (which is jaxrs:client of CXF, not a generic HTTP ...
45 votes
3 answers
45k views
What is unchecked cast and how do I check it?
I think I get what unchecked cast means (casting from one to another of a different type), but what does it mean to "Check" the cast? How can I check the cast so that I can avoid this warning in ...
10 votes
4 answers
23k views
Sending arraylist of objects using serializable
I am storing my JSON data into a arraylist of objects, my object class is Venue and I am passing that data into another activity using serializable from fragment but I am not receiving any values in ...
3 votes
3 answers
5k views
How to clone a container (f.e. ArrayList) *easily*? Is it wrong to use .clone()?
My, perhaps naive, solution for cloning an ArrayList (Vector replacement) is ArrayList<Double> alBis = (ArrayList<Double>) alOriginal.clone(); considering that because the array contains ...
3 votes
4 answers
5k views
How to get rid of this generics warning?
I am trying to mock a generic interface, and whenever I mock it, I gets this warning: The expression of type GenericInterface needs unchecked conversion to conform to GenericInterface<String> My ...
19 votes
2 answers
3k views
How to locate lambda when exception happens?
Say I have a ComparatorFactory, it has many comparators composed by a lambda: public static Comparator<SomeClass> getXCmp() { return (o1, o2) -> { Double d1 = Double....
5 votes
3 answers
2k views
Java: properly checked class instantiation using reflection
I'm trying to use one of the simplest forms of reflection to create an instance of class: package some.common.prefix; public interface My { void configure(...); void process(...); } public ...
1 vote
1 answer
14k views
How to fix incompatible types: java.lang.Object cannot be converted to java.util.List<java.lang.String> [duplicate]
I have a hashmap defined like this that I cant change private Map<String, Object> attributes; The object is a list of Strings (sometimes size == 1, other times > 1). I have an instance of ...
1 vote
2 answers
5k views
pass the arraylist with hashmap between activities in android?
I want to send the arraylist with hashmap between activities but is give me null arraylist with hashmap. Sender Activity ArrayList<HashMap<String,String>> childgame = new ArrayList<...
0 votes
2 answers
8k views
Casting Object array to generic type
I am creating a stack of generic type that is backed by an array. When I try to make a generic type array, Java does not let me. I've been told that I must create an array of type Object and cast it ...
4 votes
3 answers
1k views
Java unchecked operation cast to generic
I am wondering why the following issues a warning about an unsafe / unchecked operation: Map<String, ProxySession> sessionMap = (Map<String, ProxySession>) se.getSession()....
1 vote
1 answer
4k views
Cast a raw map to a generic map using a method, cleanly and safely in a fail early manner
Casting, instanceof, and @SuppressWarnings("unchecked") are noisy. It would be nice to stuff them down into a method where they won't need to be looked at. CheckedCast.castToMapOf() is an attempt to ...
2 votes
1 answer
5k views
Why am I getting warnings Serialize ArrayList
I'm getting odd warnings in my reading of a ArrayList of Serializable objects. Here is the code: public void loadBoard() { FileInputStream fis = null; ObjectInputStream is; try { ...