S
Saiprasad
Hi,
I am new to java and I want to know if there is a method/property for
objects that returns the name of the object that has called it.
say if I have a class for rectangle:
----------------------------------------------------------------------
public class Rectangle{
public int width;
public int height;
/* Some methods to set the width and height, find area etc*/
public void printRectangle(){
System.out.println( METHOD? + "Is having as width of"+
this.width());
}
}
------------------------------------------------------------------------
What method/property should I call in the place of "METHOD?" in
"printRectangle" above so that
If R1 is a object of Rectangle class with width 20, on calling
"R1.printRectangle()" it should print out
"R1Is having a width of 20"
Thanks,
Sai.
I am new to java and I want to know if there is a method/property for
objects that returns the name of the object that has called it.
say if I have a class for rectangle:
----------------------------------------------------------------------
public class Rectangle{
public int width;
public int height;
/* Some methods to set the width and height, find area etc*/
public void printRectangle(){
System.out.println( METHOD? + "Is having as width of"+
this.width());
}
}
------------------------------------------------------------------------
What method/property should I call in the place of "METHOD?" in
"printRectangle" above so that
If R1 is a object of Rectangle class with width 20, on calling
"R1.printRectangle()" it should print out
"R1Is having a width of 20"
Thanks,
Sai.