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]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en