Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
    Bookmark Topic Watch Topic
  • New Topic

Array representaion query

 
Poorna Nandam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Report post to moderator
can any body explain me the following code.

A[] a=new B[]{new B(),new C()};


from,
Poorna
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Poorna, Welcome to javaranch.

First of all this is the wrong forum to post this question. This question should have been in the beginner forum.

Anyways, your code is incomplete. You need to show the class hierarchy of classes A, B and C for anyone to explain the code to you.

If we take this as the class hierarchy



Then this is just dynamic assignment of elements of one type to another. Just as you can do this



You can assign an array of sub-class to an array of super-class. Arrays also have a hierarchy like normal classes

 
Poorna Nandam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thank you Anurag,

Poorna.
 
salvin francis
Bartender
Posts: 1339
11
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
This is a Duplicate post for http://www.coderanch.com/t/439314/Java-General-beginner/java/Dynamic-assignment-Array

Please refer forum rules and regulations
 
    Bookmark Topic Watch Topic
  • New Topic