0

I have a class that has an arraylist of string as private attribute and a public add method.

The code is below.

class C1{
    private int nb;
    private ArrayList<String> liste;
    public C1(int nb){ this.nb = nb; }
    public void add(String s) { liste.add(s); }
}
public class HelloWorld{
     public static void main(String []args){
         C1 c1 = new C1(0);
        c1.add("TOTO");
     }
}

this is the error :

HelloWorld.java:3: error: cannot find symbol  
  private ArrayList<String> liste;
          ^
  symbol:   class ArrayList
  location: class C1
1 error
001
  • 13,291
  • 5
  • 35
  • 66

0 Answers0