File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to represent it? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to represent it?" Watch "How to represent it?" New topic
Author

How to represent it?

Rohan Deshmkh
Ranch Hand

Joined: Aug 31, 2012
Posts: 127
Suppose Animal is a superclass And Horse is it's Subclass.
So Animal a=new Animal() would be shown as in diagram:


now i wanted to how can you represent
Animal a=new Horse()


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13868
    
  10

Simply replace the word Animal in the picture by Horse?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rohan Deshmkh
Ranch Hand

Joined: Aug 31, 2012
Posts: 127
Then how can we differentiate between
Animal a=new Horse();
and
Horse a=new Horse();
digramatically?

Of course i know the difference between the two statements in general, i just wanted to know if in a diagram i replace Animal with Horse.
How can i know whether it represents
Animal a=new Horse();
or
Animal a=new Animal();
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4240
    
    7

If you want to differentiate between those, I'd suggest labelling the reference with the type. So instead of a, use a: Animal and a: Horse (or equivalent notation).
Rohan Deshmkh
Ranch Hand

Joined: Aug 31, 2012
Posts: 127
ok thanks, i got it
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to represent it?
 
Similar Threads
needs explanation
Widening beats boxing?
Refer the program given
Overriding and Overloading
my Overload program