I have tried to compile following programme on jdk 1.6, but I have got error : javac ArrayListDemo2.java
ArrayListDemo2.java:5: '(' or '[' expected
ArrayList<
String> data = new ArrayList<String>();
^
1 error
source code:
import java.util.*;
public class ArrayListDemo2 {
public static void main(String[] args) {
ArrayList<String> data = new ArrayList<String>();
data.add("hello");
data.add("goodbye");
// data.add(new Date()); This won't compile!
Iterator<String> it = data.iterator();
while (it.hasNext()) {
String s = it.next();
System.out.println(s);
}
}
}
I have set path to "jdk 1.6 /bin" . Could anyone please suggest me how to solve this.