|
-
December 5th, 2005, 09:55 AM
#1
Printing object variables.
Hi, got a question about printing object variables .
If i create:
main class
*********************
Home first = new Home();
first=23;
System.out.println(home);
*********************'
class Home
{
public double x;
}
Why this prints something like @45de23g and after i add next method in Home class
in prints readable value i.e String value to that unicode.
public String toString()
{
return(x);
}
Can anyone explain why these both cases happen. Even thou i don't call that toString method at all.??
Thanks.
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
|
Click Here to Expand Forum to Full Width
|