• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error with latest jdk

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic