| Author |
error with latest jdk
|
mohamed mustaq
Greenhorn
Joined: Dec 19, 2005
Posts: 21
|
|
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
Joined: Nov 18, 2004
Posts: 21
|
|
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
|
Vijay<br />I blog, therefore I am<br /><a href="http://www.vijaykiran.com" target="_blank" rel="nofollow">www.VijayKiran.com</a>
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12928
|
|
|
Also, note that you need to use Eclipse version 3.1 or newer if you want support for Java 1.5.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
|
|
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
|
Java API Documentation
The Java Tutorial
|
 |
 |
|
|
subject: error with latest jdk
|
|
|