# Solved: Trying to learn Java, yall are the best at what you do, help!!!



## OneLuv (Dec 28, 2006)

I know if I don't get this, I won't ever get it. It could be something I'm typing wrong, although I compared it to the instructors. The first was MyPoint.java here is the code

public class MyPoint {
public int x;
public int y;

public String toString() {
return ("[" + x + "," + y + "]");
}
}

The second was TestMyPoint.java and here's the code:

public class TestMyPoint
{
public static void main(String[] args)
{
MyPoint start = new MyPoint();
MyPoint end = new MyPoint();

start.x = 10;
start.y = 10;
end.x = 20;
end.y = 30;

System.out.println("Start point is " + start);
System.out.println("End point is " + end);
System.out.print();
}
}

when I try and compile the second one, I get 4 errors, Each one pointing to the "M" in MyPoint. Says "cannot find symbol". The 5th error says cannot find symbol, and is pointing to the ( . ) after out in System.out.println();

I almost want to uninstall and reinstall my jdk, but since it's compiled everything else ive done, I don't know why it's doing this.


----------



## Remus_Lupin (May 6, 2007)

Did you import the MyPoint class at the begining of TestMyPoint class?

As for your fifth error it is probably because you are trying to output the the entire object without referring to specific variables inside that object , you should do

```
System.out.println("Start point is " + start.x + ", " + start.y);
```
 and same for end.


----------



## Chicon (Jul 29, 2004)

Hi OneLuv,

Remus_Lupin is right : you need to make an import of MyPoint if the class is not in the same directory of TestMyPoint.
Otherwise, the import statement is not mandatory if the classes are stored in the same directory : compile first MyPoint then TestMyPoint.

Also, the following lines :
*
System.out.println("Start point is " + start);
System.out.println("End point is " + end);
*

may be replaced by :
*
System.out.println("Start point is " + start.toString());
System.out.println("End point is " + end.toString());
*


----------



## OneLuv (Dec 28, 2006)

See, something is way wrong. The thingy im doing is thru the Sun learning. They give you the instructions, and if you find yourself stuck, there is an instructor demo of what's suppose to be done. What I posted, is what he did. Of course on the video it worked fine, but for me it's not working. I can't tell you how long I tried to get it to work. The class file for MyPoint is in the same directory. When I tried I kept looking up and looking at all the explanations for code errors I could find. I'll research all the stuff in the MyPoint.java to see what it means. I even printed mines and held it up again the copy of the code on the instructions just to see if I was missing something. And of course there is no way to tell them.

Thanks so much. In the interim, I bought a Java for absolute dummies. Im reading it now to see if I missed something important yet simple from the start. So far I haven't, so I don't know where Im missing it. The second assignment...the same thing. So I know its not me. Installed the jdk on a different PC and tried it again. I dunno, but I will make it say what you suggested. Thanks again


----------



## OneLuv (Dec 28, 2006)

Thanks for everyone who responded. I feel like such an idiot! Well, I decided to get some sleep first (I'd been up for 2 days) Then when I started reading the absolute beginner's book it dawned on me. The CLASSPATH wasn't set...well at least not to that hard drive. My previous lessons were all done on another hard drive. So when I set the CLASSPATH, one of them worked find.

The one posted the last line of code: System.out.println(); well I think the instructor made a mistake and forgot this was lesson 1. I deleted it, and it compiled and ran...no problems.

Thanks again for your help.


----------

