can not be, because you're not thinking right, the objects not be class.
If you want to know that object is, you need to access the objects and get
the properties, then you know that object is.
Example:

 public void method(Person p) {
       if (p.getName().equal("anthony")){
           // p is anthony
       } else if (p.getName().equal("richard")) {
           // p is richard
       }
       ......
}

this is the only way.

Hope it's help and sorry for my English!!!!

  }
2010/4/13 <[email protected]>

>
>
>
> Hello,
>
> well maybe your are searching for "Instance of Method".
> If i am right you can ask (instance of )
> Example:
> Room       go1 = new Room();
> System.out.println( go1 instanceof Room );       // true
> System.out.println( go1 instanceof GameObject ); // true
> System.out.println( go1 instanceof Object );     // true
>
> GameObject go2 = new Room();
> System.out.println( go2 instanceof Room );       // true
> System.out.println( go2 instanceof GameObject ); // true
> System.out.println( go2 instanceof Object );     // true
> System.out.println( go2 instanceof Player );     // false
>
> Object     go3 = new Room();
> System.out.println( go3 instanceof Room );       // true
> System.out.println( go3 instanceof GameObject ); // true
> System.out.println( go3 instanceof Object );     // true
> System.out.println( go3 instanceof Player );     // false
> System.out.println( go3 instanceof String );     // false
>
> Hope it's help..
>
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: [email protected] [mailto:
> [email protected]] Im Auftrag von mcalex
> Gesendet: Dienstag, 13. April 2010 11:00
> An: Java Programming Online Training Course By Sang Shin
> Betreff: [java programming] Re: Object instance identification
>
> I don't know, but I think you don't need to worry about this stuff
> with java.
> Assuming Person has variables Name and DOB (both Strings):
>
> // Create the objects
> Person richard = new Person();
> richard.Name = "Richard";
> richard.DOB = "10/11/1988";
>
> Person anthony = new Person();
> anthony.Name = "Anthony";
> anthony.DOB = "7/12/1989";
>
> // prints person details
> public void method(Person person)
> {
>  System.out.println("Hello " + person.Name + ", you were born on " +
> " person.DOB);
> }
>
> when you pass method(richard), you get: Hello Richard, you were born
> on 10/11/1988
> and passing method(anthony) results in: Hello Anthony, you were born
> on 7/12/1989
>
>
> hth
> mcalex
>
> On Apr 13, 2:14 pm, Anthony Lam <[email protected]> wrote:
> > Hi mihai,
> >
> > Thanks very much for giving such a detail explanation, but I think I am
> not making my question clear enough and I think you answer does not solve my
> query. Let me clarify a little bit more of what I am asking.
> > e.g  Person anthony = new Person();
> >       Person richard = new Person();
> >       method(anthony);  --- anthony object instance is being passed to
> method
> >       method(richard);    --- richard object instance is being passed to
> method
> >
> >       public void method(Person p) {
> >
> >          within the method's code here. How can I tell the Person object
> instance argument passed here is the object
> >          instance of Anthony or object instance of Richard.
> >
> >          I might like to perform if P is Anthony instance then print out
> "Hello Anthony"! or else if P is richard instance then I
> >          would print out "Hello Richard" or some other kind of logic
> depending on the object passing in.
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]<javaprogrammingwithpassion%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>
> #####################################################################################
> SEB AG
> Hauptsitz
> Frankfurt am Main
> HRB 6800
>
> Vorsitzender des Aufsichtsrates: Fredrik Boheman
>
> Vorstand: Jan Sinclair, Vorsitzender
> Renate Bloß-Barkowski
> Liselotte Hjorth
> Ian Lees
> Jens Liehr
>
>
> #####################################################################################
> Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte
> Informationen.
> Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich
> erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie
> diese E-Mail (inklusive aller Anhänge).
> Bitte fertigen Sie keine Kopien an oder bringen den Inhalt anderen Personen
> zur Kenntnis.
> E-Mails sind anfällig für Datenverfälschungen, können abgefangen werden und
> Computerviren verbreiten.
> Außer für Vorsatz und grobe Fahrlässigkeit lehnen wir jede Verantwortung
> für derartige Vorgänge ab.
>
> This e-mail is confidential and may contain legally privileged information.
> If you have received it by mistake, please inform us by reply e-mail and
> then delete it (including any attachments) from your system.
> You should not copy it or in any other way disclose its content to anyone.
> E-mail is susceptible to data corruption, interception, unauthorised
> amendment, tampering and virus infection.
> We do not accept liability for such actions or the consequences thereof.
>
> #####################################################################################
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]<javaprogrammingwithpassion%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>
> To unsubscribe, reply using "remove me" as the subject.
>

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to