Yes, you deleted one of constructors - you deleted no argument constructor (personally I think it is right), unless your instructions says differently. Default constructor compiler adds one in case you don't define yours. In your case you defined constructor with 2 parameters and one constructor with no argument (once again, it is called no argument, and not default).
naomi newman wrote:i thought i deleted the default constructor. the default constructor wouldnt have any arguments right?
What does that mean? That means, that your array elements suppose to be points, these points can/should be constructed using MyPoint class you just created.
naomi newman wrote:Write a test class named Lab12 with a main method to create a 2 by 3 array filled with points
naomi newman wrote:(0.5, 1.2) (0.0, 3.14) (15.0, 27.5)
(6.6, 7.7) (1.2, 2.1) (12.0, 127.0)
naomi newman wrote:pt = (0.5, 1.2)
pt = (0.0, 3.14)
pt = (15.0, 27.5)
pt = (6.6, 7.7)
pt = (1.2, 2.1)
pt = (12.0, 127.0)
Check carefully, aren't you missing "," before 27.5?
naomi newman wrote:its giving me an error for 27.5
It is not saying that. Errors messages issued by compilers usually are more explicit and telling more details. Usually you can see the line number where the error occured and some other useful accurate information.
naomi newman wrote:now its telling me
Array constants can only be used in initializers
as an error message when i add the elements in the pointMatrix
naomi newman wrote:I see now that my for loop for printing the array is incorrect. can you tell me what i have done wrong?
You can do it by setting the individual elements of the arrays, but you will soon see that an array initialiser like that is much quicker to write. Also no risk of getting the indices out of bounds.
naomi newman wrote:okay! I see my problem. I now have
If you look in Java Puzzlers by Bloch and Gafter, it has a question about how to print such an array. I actually got that one right when I first saw it. Use System.out.println(this method);. You should also override the toString() method to return something you can understand, e.g.
Naomi Newman wrote:I see now that my for loop for printing the array is incorrect. can you tell me what i have done wrong?
[Point: x=123, y=456]