Array of objects


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Array of objects

  1. #1
    Join Date
    May 2006
    Posts
    5

    Array of objects

    hi ,
    could u tell me how can we create an array of objects
    thanx

  2. #2
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    the same as you create any other array:

    Student[] students = new Student[30];

    See the Java Tutorial: http://java.sun.com/docs/books/tutor...OfObjects.html

  3. #3
    Join Date
    May 2006
    Posts
    5
    thanks
    but after creating array of objects of class student ,how i can store data to the
    attributes of class and further retrieve them.

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    To retrieve an object contained in the array, you need to "get" that particular student object. You use the array index to refer to a particular object. You either know the storage index of the student, or you search for the particular student. Once you have that student object you can modify data members of the instance, or execute methods of that instance.

    The usual method to retrieve is just a "getStudent" which returns an object of class Student. Usually you'll have some information about a particular student which can be used to uniquely identify the student - pass that info as the argument to your method. Can also do a "modifyStudent" method which can open up the student instance for your modification or addition of values.

Similar Threads

  1. How to create objects (JButton) array?
    By barbato in forum Java
    Replies: 6
    Last Post: 04-17-2006, 11:21 PM
  2. Replies: 1
    Last Post: 02-06-2006, 01:48 AM
  3. Saving Objects in an Array...?
    By dotnetforever in forum .NET
    Replies: 2
    Last Post: 02-15-2005, 08:16 PM
  4. JTable from array of Objects
    By styles in forum Java
    Replies: 2
    Last Post: 04-17-2001, 05:03 AM
  5. filling array objects
    By Jeanie in forum Java
    Replies: 1
    Last Post: 03-08-2001, 11:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center