Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HeadFirst Java Page 268 5 minute mystery Urgent Help  RSS feed

 
Elim Banda
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please look at this code and explain to me what is happening when v2 object is created what does (alist) mean I have never come across this??

 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elim Banda wrote:Please look at this code and explain to me what is happening when v2 object is created what does (alist) mean I have never come across this??



All that is happening is that you are creating a new V2Radiator object and passing it an ArrayList parameter.
 
Elim Banda
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it passes in everything in the Arraylist? what does it then do with the arraylist?
 
Ganesh Patekar
Bartender
Posts: 696
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elim Banda wrote:So it passes in everything in the Arraylist? what does it then do with the arraylist?

  • You better post complete code, so more people may try to answer you

  • Elim Banda wrote:V2Radiator v2 = new V2Radiator(aList); //What does this statement do?

  • You are creating an object of V2Radiator and passing a reference of object of ArrayList assigned to aList reference variable to the parameterized constructor of V2Radiator class.
  • Hope this is the program you are talking about. Source: Head First Java Ch.9 Page No 268


  • Look at line no 6, aList reference variable is passed to the parameterized constructor of V2Radiator where It adds 5 new objects of SimUnit to the ArrayList object referred by aList, each object of SimUnit class having instance variable String botType assigned by value "V2Radiator" which is also passed as argument to the parameterized constructor of SimUnit class.
  •  
    Don't get me started about those stupid light bulbs.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!