File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error with latest jdk

 
mohamed mustaq
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am using eclipse ide and i am using jdk1.5
if i try to run the program with arraylist method.
it throws a error.
this is my program
/*
* Created on Jan 17, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package prac;
import java.util.*;


/**
* @author mohamed mustaq
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class prac1 {

public static void main(String args[])
{
ArrayList<String> a=new ArrayList<String>();
a.add(0,"zero");
a.add(1,"one");
a.add(2,"two");
a.add(3,"three");
printAL(a);
if(a.contains("three")){
a.add("four");
}
a.remove(2);
printAL(a);
if(a.indexOf("four")!=4){
a.add(4,"4.2");

}
printAL(a);
if(a.contains("two")){
a.add("2.2");

}
printAL(a);
}
public static void printAL(ArrayList<String> al){
for(String element :al){
System.out.print(element+" ");
}
System.out.println(" ");

}

}
and the error is
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "<", invalid AssignmentOperator
Syntax error on token "=", != expected
Syntax error on token "<", ( expected
Syntax error on token "(", invalid Expression
Syntax error, insert "}" to complete ClassBody

at prac.prac1.main(prac1.java:21)

may anyone help in this?
 
Vijay Kiran
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to change your project compliance settings in eclipse to 1.5.
Goto project -> Properties -> Java Compiler

Enable Project specific settings check box
Under JDK compliance select 5.0 in all the dropdown boxes.


Regards,

www.VijayKiran.com
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, note that you need to use Eclipse version 3.1 or newer if you want support for Java 1.5.
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the above suggestions don't help, please post the EXACT error message that you get. Otherwise, we will waste your time by just guessing the problem and a solution.

Layne
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic