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.
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.
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!