1

I was writing a program in our activity in school and when I compile I get the following error:

enter image description here

I am also using notepad++ to compile This is the code:

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!

dur
  • 15,689
  • 25
  • 79
  • 125
iri0021
  • 51
  • 1
  • 1
  • 13

1 Answers1

6

You are using raw types with the ArrayList

replace it with

ArrayList<String> arrayList = new ArrayList<>();

More info : What is a raw type and why shouldn't we use it?

Community
  • 1
  • 1
Yassin Hajaj
  • 21,337
  • 9
  • 51
  • 89