java - Assign subclasses to each array element (run-time type) -


i have base class building , subclasses house , school. have declared array of building objects following way. not sure how assign subclasses each array element (run time type).

building[] house = new building[3]; building[] school = new school[2]; 

you can use instanceof determine subclass

if (building instanceof house) {     house[0] = building; } 

Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -