| Author |
An array of objects????
|
Sam Bluesman
Ranch Hand
Joined: Nov 21, 2004
Posts: 188
|
|
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?
|
Moosey knows best
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12921
|
|
Ofcourse. See the tutorial: Arrays [ October 25, 2006: Message edited by: Jesper Young ]
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24057
|
|
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.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Sam Bluesman
Ranch Hand
Joined: Nov 21, 2004
Posts: 188
|
|
|
Thanks guys - very helpful
|
 |
 |
|
|
subject: An array of objects????
|
|
|