``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''
Hama Kamal wrote:
hey guys,,, please check the problem bleow
1-is it a correct way to call the method in this way?
??
Hama Kamal wrote:
2-when i run it it gives this error
createobjectdemo.Rectangle@c17164
Seetharaman Venkatasamy wrote:
Hama Kamal wrote:
hey guys,,, please check the problem bleow
1-is it a correct way to call the method in this way?
??
yes if that method has a return type.
Hama Kamal wrote:
2-when i run it it gives this error
createobjectdemo.Rectangle@c17164
this is not an error. it is just default string representation of your Rectangle object. if you want the representation more meaningful, then override toString method in Rectangle class.
``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''
``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''
Hama Kamal wrote:Thank you guys ,, i got it
OCPJP 6.
In Your Pursuit Towards Certification, NEVER Give Up.
OCPJP 6.0
So I was wondering if there was a way 'rectOne' or 'rectTwo' could display as output.but it should be either rectOne or rectTwo
OCPJP 6.
In Your Pursuit Towards Certification, NEVER Give Up.
Ikpefua Jacob-Obinyan wrote:@Achilleas...Thanks man that was the idea I had all along and thats what I did:
Now I got confused when @Hama said;So I was wondering if there was a way 'rectOne' or 'rectTwo' could display as output.but it should be either rectOne or rectTwo
OCPJP 6.0
Achilleas wrote:MAN!!! You just gave a GREAT idea!!! An Object to know the name and type of the variable it is pointed to. Or to be more specific a list of all variables which point to it!!
OCPJP 6.
In Your Pursuit Towards Certification, NEVER Give Up.
``Worry does not empty tomorrow of its sorrow; it empties today of its strength.''
Matthew Brown wrote:println has a number of overloaded versions. One of them takes an Object as the argument, and when that one is called it uses toString() to work out what to display.
If you check the source code, you'll see this in PrintStream (the actual type of System.out):
And in String you'll find this:
So toString() gets called, even though you never call it yourself.