Instance of function?
Hi,
I need to know about the InstanceOf function! how is it used? and in which cases? which library of java should i be including to use it?
My problem( if u r interested):
I made a class (A). and I have to create objects of this class in various other classes which are independant of each other. So need to get the object of class (A), probably, from that class itself. How do i do this? I thought instanceOf could be the correct answer for this. Hope someone can help!
thank in advance,
Rajesh Rapaka.
[542 byte] By [
R.Rajesha] at [2007-10-2 21:07:57]

> Hi,
>
> I need to know about the InstanceOf function! how is
> it used? and in which cases? which library of java
> should i be including to use it?
>
> My problem( if u r interested):
> I made a class (A). and I have to create objects of
> this class in various other classes which are
> independant of each other. So need to get the object
> of class (A), probably, from that class itself. How
> do i do this? I thought instanceOf could be the
> correct answer for this. Hope someone can help!
>
> thank in advance,
> Rajesh Rapaka.
It's not a function (functions are called methods in Java) but an operator. And you don't need to import anything for that.
You use it to check if a class is of a certain type:
if(A instanceof Object) {
System.out.println("Hey A is an Object!");
}
> Of course every class is a java.lang.Object in Java, but you know what
> I mean, right?
No. But I don't know what the OP has in mind either, so I'm the one to blaim
here. When I first read the title 'Instance of function', my mind went like:
"pointers to member functions (C++), function objects etc. etc." Maybe
it's just because it's Saturday but I don't understand the question ;-)
kind regards,
Jos
JosAHa at 2007-7-13 23:53:41 >
