aspose file tools*
The moose likes Java in General and the fly likes getting compile error ,if try to compile with jdk 1.6. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "getting compile error ,if try to compile with jdk 1.6." Watch "getting compile error ,if try to compile with jdk 1.6." New topic
Author

getting compile error ,if try to compile with jdk 1.6.

Ashish Anil Khadilkar
Greenhorn

Joined: Jul 13, 2006
Posts: 18
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.
Ashish Anil Khadilkar
Greenhorn

Joined: Jul 13, 2006
Posts: 18
it worked.I just removed the old path of jdk 1.4 from system variables (My computer/Environmental variables. thanks
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959


It won't compile because you defined ArrayList<String> data = new ArrayList<String>(), so data can only accept String and not Date.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting compile error ,if try to compile with jdk 1.6.
 
Similar Threads
Static member problem
SWINGS Over Use of Vectors
Error compiling JSP
JTable
JTable