Java ArrayList does not work

-2

I'm having problems with ArrayList

import java.util.Scanner;
public class ArrayList{
  public static void main(String[] args) {
    ArrayList<ArrayList> agenda = new ArrayList<ArreyList>();
    Scanner input = new Scanner(System.in);
    agenda.add("Teste");
    System.out.println(agenda);
  }
}

Whenever I compile it gives the error

  

ArrayList.java:1: error: ArrayList is already defined in this compilation unit   import java.util.ArrayList;

and about the ArrayList of

  

ArrayList.java:5: error: type ArrayList does not take parameters   ArrayList schedule = new ArrayList ();

It says that the ArrayList does not receive parameters but still taking out the parameters it does not compile, it shows as if the .add function is not known ArrayList.java:7: error: can not find symbol agenda.add ("Test");

    
asked by anonymous 23.05.2018 / 13:04

1 answer

0

What a crazy class this is, consider doing so:

import java.util.ArrayList;
    import java.util.List;
    import java.util.Scanner;

    public class MinhaClasse {
        List<String> agenda = new ArrayList<String>();
        Scanner scanner = new Scanner(System.in);
        String entrada = scanner.nextLine();

        agenda.add(entrada);

        for (String ag : agenda) {
            System.out.println(ag);
        }
    }
    
23.05.2018 / 15:01