• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding abstract class

 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I know that DateFormat is an abstract class. So I cannot instantiate an object of this type. But then how can I say:



How come I can declare and construct an array of DateFormat type i.e a class that is abstract? How does the JVM differentiate between the object instantiation and an array constructed to hold abstract class type objects?
 
Paul Clapham
Sheriff
Pie
Posts: 20164
24
MySQL Database
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's like asking how the grocer differentiates between some eggs and the box used to put the eggs in. They are entirely different things.

Creating an array of type X doesn't create any objects of type X, it simply creates an object which could hold such objects. The entries of that array are all initialized to null.
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:That's like asking how the grocer differentiates between some eggs and the box used to put the eggs in. They are entirely different things.

Creating an array of type X doesn't create any objects of type X, it simply creates an object which could hold such objects. The entries of that array are all initialized to null.


Thanks Paul..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic