Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (3.5k points)

For example:


Note: uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

1 Answer

0 votes
by (46k points)

This develops up in Java 5 and later if you're doing collections without type specifiers (e.g., Arraylist() rather of ArrayList<String>()). It implies that the compiler can't check that you're using the collection in a type-safe way, using generics.

To get rid of the signal, just be particular about what type of objects you're storing in the collection. So, rather of

List myList = new ArrayList();


List<String> myList = new ArrayList<String>();

In Java 7 you can reduce generic instantiation by applying Type Inference.

List<String> myList = new ArrayList<>();

Related questions

+12 votes
2 answers
0 votes
1 answer

Browse Categories