Hi, when I try to compile the following I get the error below. However if I get rid of the two lines of code in the shape class it runs fine.
I don't understand what's going on - I'm calling the same show() method for both mypoint and mypoint2 objects (creating a mypoint2 object in the shape class). Why does the program work when the show() method is called for the mypoint object, but gives an error the the mypoint2 object?
Thanks.
error:
test.java:35: error: <identifier> expected
mypoint2.show();
class point{ double x=0; double y=0; public point(double x2,double y2) { x=x2; y=y2; } public point() { x=0; y=0; } public void show() { System.out.println("X: "+x+" Y:"+y); } } class shape{ point mypoint2=new point(76,67); //program won't run with these 2 lines of code, but will work if these 2 lines are deleted mypoint2.show(); } public class test{ public static void main(String[] args){ point mypoint=new point(76,7); System.out.println("x and y of point 1 "); mypoint.show(); } }