method to access the name of the object that got created.
- From: "Saiprasad" <r.saiprasad@xxxxxxxxx>
- Date: 28 Feb 2007 02:43:23 -0800
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.
.
- Follow-Ups:
- Re: method to access the name of the object that got created.
- From: Dimitri Kurashvili
- Re: method to access the name of the object that got created.
- From: Gordon Beaton
- Re: method to access the name of the object that got created.
- Prev by Date: Re: java obfuscator for ejb
- Next by Date: [NETBEANS] How to display query result in a grid
- Previous by thread: JUNIT questions
- Next by thread: Re: method to access the name of the object that got created.
- Index(es):
Relevant Pages
|