printing java object in the method
How to print the object that has called the method in the method itself.
class abc{
public method1()
{
S.o.p("Print the object that has called this method")
?
}
psvm(string a[])
{
abc aa=new abc();
aa.method1();
}
}
Thanks
Sir
[317 byte] By [
msirajuda] at [2007-9-29 12:27:25]

> Or make a new exception and parse the stack trace.> This has a performance penalty, though.That wont get the object that's making the call (the 'this' of the method that's making the call), but only the class and the method
dpza at 2007-7-15 2:19:33 >

Ah... then you will have to pass the object in, though Rommie's code sample will only print the class name. msirajud, if you print out obj.toString() instead, then Rommie's sample may be just what you're after.