-
Help! compiling problem!
I took a block of code out of a book. I am going to use
it as a skeleton for my code. Can someone tell me why it
doesn't compile ? First is the code, then I provide the
errors. Thanks!
///////////////////////////////////////////////////////
public abstract class Polyline extends Shape
{ //Begin class
private ListPoint start;
private ListPoint end;
//Construct a polyline from an array of points
public Polyline(Point[] points)
{ //Begin Polyline method
if(points!=null) //Make sure there's an array
{ //Begin if
//Create a one point list
start = new ListPoint(points[0]); //1st point is the start
end = start; //as well as the end
//Now add the other points
for(int i=1; i<points.length; i++)
addPoint(points[i]);
//Add a point object to the list
public void addPoint(Point point)
{
ListPoint newEnd = new ListPoint(point); //Create a new ListPoint
if(start==null)
start=newEnd; //Start is same as end
else
end.setNext(newEnd); //Set next variable for old end as new end
end=newEnd; //Store new point as end
}
}//End if
} //End Polyline method
} //End class
///////////////////////////////////////////////////////
C:\java>javac Polyline.java
Polyline.java:20: illegal start of expression
public void addPoint(Point point)
^
Polyline.java:28: ';' expected
}
^
Polyline.java:17: cannot resolve symbol
symbol : method addPoint (Point)
location: class Polyline
addPoint(points[i]);
^
3 errors
///////////////////////////////////////////////////////
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks