L
lonelyplanet999
Hi,
I wrote below code which failed in compilation as compiler complained
the methods add (java.lang.String) are can't solve symobols. The same
method succeeded for LinkedHashSet & TreeSet objects. Why it failed
for ArrayList objects ? The syntax description for ArrayList add
method accepts object type instance.
import java.util.*;
public class ArrayListx {
public static void main (String [] args) {
ArrayList arl = new ArrayList();
arl.add("Chicago");
arl.add("Detroit");
arl.add("Atlanta");
arl.add("Denver");
Iterator it = arl.iterator();
while (arl.hasNext()) {
System.out.println("city "+it.next());
}
for (int i=0; i<4; i++) {
}
}
}
I wrote below code which failed in compilation as compiler complained
the methods add (java.lang.String) are can't solve symobols. The same
method succeeded for LinkedHashSet & TreeSet objects. Why it failed
for ArrayList objects ? The syntax description for ArrayList add
method accepts object type instance.
import java.util.*;
public class ArrayListx {
public static void main (String [] args) {
ArrayList arl = new ArrayList();
arl.add("Chicago");
arl.add("Detroit");
arl.add("Atlanta");
arl.add("Denver");
Iterator it = arl.iterator();
while (arl.hasNext()) {
System.out.println("city "+it.next());
}
for (int i=0; i<4; i++) {
}
}
}