Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An array of objects????

 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi people.

Let's say i have to create a student object - say student name, id and phone number. Is it possible to create an array of these student objects?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ofcourse. See the tutorial: Arrays

[ October 25, 2006: Message edited by: Jesper Young ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create an array of references to Students; just as normal variables are just references to objects, array elements are, too. So when you construct an array of Student it will contain all null Student references. If you want to construct a Student for each position in the array, then could use a loop to do that:



More likely you'd have a file containing Student data, and you read it in a loop and construct Student objects based on the data.
 
Sam Bluesman
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys - very helpful
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic