I am working on homework so I just want to fix my compile error so I can keep working on it. I need to make a PointList class that keeps a list of Point objects in an ArrayList. The PointList class should accept any object that is an instance of the Point class, or a sub-class of Point.
I keep getting a compiler error that says
> required: Point<Integer>
found: no arguments
reason: actual and formal argument lists differ in length
where E is a type-variable:
E extends Object declared in class PointList
I really don't understand what I am missing I've gone through the book and can't seem to see why I get this error. I have Point class made and test done but can't seem to get it to compile.
public class PointListTest{
public static void main(String[] args){
//create point ints
Point<Integer> pointOne = new Point<Integer>(1,2);
Point<Integer> pointTwo = new Point<Integer>(3,4);
Point<Integer> pointThree = new Point<Integer>(5,6);
//make object PointList pointlist for int
PointList<Point<Integer>> newPointList = new PointList<Point<Integer>>();
//add points to list
newPointList.add(pointOne);
newPointList.add(pointTwo);
newPointList.add(pointThree);
This is what I have so far for PointList
public class PointList<E>{
private ArrayList<Point> myPoint;
E data;
public PointList(E obj){
ArrayList<Point> myPoint = new ArrayList<Point>();
data = obj;
}
}
Point class
public class Point<T extends Number>{
//field values
private T xCordinate;
private T yCordinate;
//constructor
//@param x the x cordinate
//@param y the y cordinate
public Point(T x, T y){
xCordinate = x;
yCordinate = y;
}//end constructor
public void setX(T x){
xCordinate = x;
}//end setX
public void setY(T y){
yCordinate = y;
}//end setY
public T getX(){
return xCordinate;
}//end getX
public T getY(){
return yCordinate;
}//end getY
}//end pointlist
If I could just get it to compile so that I could keep working on it I'd be extremely grateful.