ARRAYS and OBJECTS
Just as you created arrays of primitive data types,
you can also create arrays of objects.
Example:
Student [] stu = new Student[10]; // create an array of Student objects
for(n=0;n<10;n++)
stu[n] = new Student(); // note in the parenthesis
supply the parameters needed
// by the class constructor .. In this loop we are actually
// creating 10 objects. A reference to each object is stored
// in each respective array element
String s;
for(n=0;n<10;n++)
{
s=JOptionPane.showInputDialog("enter student
name ");
stu[n].enterName(s);
// calling the enterName method in a loop on each of the
// 10 stu objects and passing a student's name. This assumes
// that the 'enterName' method wants a String parameter.
}
String out="";
for(n=0;n<10;n++)
out += stu[n].getName(); // get the 10 stu
objects's names and concatenate them for printing
// This assumes that the "getName" method returns the name