To your first question, good point. You didn't call toString()
directly but you also don't have a constructor for the class. Try one
and see what happens to toString(). True it is the overridden toString
() now. Looks like println() uses it huh? Print some more lines then.

On the second question, I think everyone else has answered it.

On Aug 13, 6:04 pm, Caleb Josue Ruiz Torres <[email protected]> wrote:
> this doubt don't let me sleep, help me to understand
>
> i got this Class
> --------------------------------------------------------
> public class MyPoint {
>   public int x;
>   public int y;
>
>     public String toString() {
>     return ("[" + x + "," + y + "]");
>   }}
>
> ---------------------------------------------------------
>
> then i use this other Class to test the first one
> ---------------------------------------------------------
> 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);
>     }
>
> }
>
> -------------------------------------------------------------
>
> and the ouput is:
> Start point is: [10,10]
> End point is: [20,30]
>
> WHY? if i didn't call the toString Method in any line
>
> then i change the name of the method toString to the name angelo (lol)
> as follow
> public class MyPoint {
>   public int x;
>   public int y;
>
>     public String angelo() {
>     return ("[" + x + "," + y + "]");
>   }
>
> }
>
> and the ouput was :
>
> Start point is: mypo...@19821f
> End point is: mypo...@addbf1
>
> please help me to understand this topic!

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to