What causes javac to issue the "uses unchecked or unsafe operations" warning

byeol·2022년 12월 8일
0


before

 Set<Integer> set = new TreeSet(Collections.reverseOrder());

after

 Set<Integer> set = new TreeSet<>(Collections.reverseOrder());

This comes up in Java 5 and later if you're using collections without type specifiers (e.g., Arraylist() instead of ArrayList()). It means that the compiler can't check that you're using the collection in a type-safe way, using generics.

자바 5에 등장, <>없이 사용할 경우 나타난다.

To get rid of the warning, you need to be specific about what type of objects you're storing in the collection. So, instead of

profile
꾸준하게 Ready, Set, Go!

0개의 댓글