Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-26-2007, 02:07 AM
Member
 
Join Date: Oct 2007
Posts: 7
Bibendum is on a distinguished road
Java confused over Generics?
I have just installed java on a new computer, and it doesn't seem to recognise the syntax for Generic classes and methods.

I copied some code from my old computer over and it runs fine - but when I try to compile code (even with no changes) I get errors that I didn't get before.

Code:
ConnectionPoint.java:7: <identifier> expected private ArrayList<Line> connectionLines; ^ ConnectionPoint.java:11: '(' or '[' expected connectionLines=new ArrayList<Line>(); ^ ConnectionPoint.java:14: <identifier> expected public void assignConnections(ArrayList<Line> cL){connectionLines=cL ^ ConnectionPoint.java:54: ')' expected } ^
Here's the full code, though I doubt there's any problems with it. It compiled on my other computer.

Code:
package SimpleGeometry; import java.util.*; import SimpleGeometry.*; public class ConnectionPoint extends EPoint{ private ArrayList<Line> connectionLines; public ConnectionPoint(int x, int y){ super(x,y); connectionLines=new ArrayList<Line>(); } public void assignConnections(ArrayList<Line> cL){connectionLines=cL;} public void removeConnection(Line l){connectionLines.remove(l);} public void addConnection(Line l){connectionLines.add(l);} public void tryConnection(Line l){ if(isConnectedTo(l)){ addConnection(l); } } public boolean isConnectedTo(Line l){ EPoint p1=l.getP1(); EPoint p2=l.getP2(); if(equals(p1)||equals(p2)){ return true; } return false; } public ArrayList<Line> getConnections(){ return connectionLines; } public String toCString(){ Line l; String s=""; Iterator<Line> iter = connectionLines.iterator(); while(iter.hasNext()){ l=(Line)iter.next(); s+= l.toString(); s+="\n"; } return s; } }
I've installed all the necessary components of java (the SDK, J2RE, and JDK) without a problem. Please help!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-26-2007, 06:15 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
It might be possible that an earlier version of java or the jre (came pre-installed and) is being used by your computer. Check with:
Code:
C:\jexp>java -version java version "1.6.0_03" Java(TM) SE Runtime Environment (build 1.6.0_03-b05) Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-26-2007, 08:01 AM
Member
 
Join Date: Oct 2007
Posts: 7
Bibendum is on a distinguished road
That's exactly the same version number I have. :/
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-26-2007, 08:23 AM
Senior Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 102
wsaryada is on a distinguished road
are you compiling the code from command prompt or using an IDE? please make sure the JDK use in IDE support the Generic feature of Java.
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The words *game* in java programming :confused: ibmzz Advanced Java 1 01-23-2008 11:23 AM
Java Generics with legacy code (II) JavaForums Java Blogs 0 01-11-2008 09:12 PM
Java Generics with legacy code (I) JavaForums Java Blogs 0 01-11-2008 09:12 PM
Generics sireesha New To Java 2 01-11-2008 01:08 AM
Java Generics (an introduction) Java Tutorial Java Tutorials 0 11-27-2007 08:50 PM


All times are GMT +3. The time now is 02:35 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org