Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unchecked conversion

I don't want to supress warnings. Is there another way to handle this warning?

"The expression of type Iterator needs unchecked conversion to conform to Iterator"

Iterator<String> it = schemaJSON.getJSONObject("body").keys();
like image 697
stefana Avatar asked Dec 04 '13 14:12

stefana


People also ask

What does unchecked assignment mean?

Unchecked assignment: 'java.util.List' to 'java.util.List<java.lang.String>' It means that you try to assign not type safe object to a type safe variable. If you are make sure that such assignment is type safe, you can disable the warning using @SuppressWarnings annotation, as in the following examples.

What is unchecked type?

Unchecked cast means that you are (implicitly or explicitly) casting from a generic type to a nonqualified type or the other way around.

What does the compiler mean by an unchecked call?

The warning tells you that the compiler has encountered a condition that it can't guarantee the sense of. You should avoid having this kind of thing.


1 Answers

You can find your answere here: Type Safety warning with JSON Iterator

Iterator<?> it = schemaJSON.getJSONObject("body").keys();

while(it.hasNext())
{
     String next = (String) it.next();
     ...
like image 141
Ben Avatar answered Oct 05 '22 19:10

Ben