[英]Java program uses unchecked or unsafe operations
I was writing a program in our activity in school and when I compile I get the following error: 我在学校的活动中正在编写程序,编译时出现以下错误:
I am also using notepad++ to compile This is the code: 我也在使用notepad ++进行编译,这是代码:
import java.util.ArrayList;
import java.util.Collections;
public class Main {
public static void main(String[] args) {
ArrayList arrayList = new ArrayList();
arrayList.add("A");
arrayList.add("B");
arrayList.add("C");
arrayList.add("D");
arrayList.add("E");
System.out.println("Before Reverse Order: " + arrayList);
Collections.reverse(arrayList);
System.out.println("After Reverse Order: " + arrayList);
}
}
I am new to learning java so any help is appreciated thank you! 我是学习Java的新手,因此非常感谢您的帮助!
You are using raw types with the ArrayList
您正在将原始类型与
ArrayList
replace it with 替换为
ArrayList<String> arrayList = new ArrayList<>();
More info : What is a raw type and why shouldn't we use it? 更多信息 : 什么是原始类型,为什么我们不应该使用它呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.