Results 1 to 3 of 3
  1. #1
    Jack is offline Senior Member
    Join Date
    Jun 2007
    Posts
    130
    Rep Power
    0

    Default array of objects

    I want to store the parameters that the user enter into an array call "pupil" but I can't do it
    This is the code:
    Java Code:
    public class Main
    {
        public static void main(String[] args) throws Exception
        { 
           Pupil ingr;
           char createProd;
           int counter=0;
           do{
            System.out.println(" Do you want to start to enter products s/n");
            createProd= (char)System.in.read();
            System.in.read();
            if (createProd!= 'N') 
            { 
                    ingr= new Pupil();
                    String id = Console.readLine("Identification");
                    int idd = Integer.parseInt(id);
                    String name = Console.readLine("Name:");
                    String lastname= Console.readLine("Lastname:");
                    String age = Console.readLine("age");
                    int aged1= Integer.parseInt(age);
                    ingr.setId(idd);
                    ingr.setName(name);
                    ingr.setSurname(surname );  
                    counter++;   
            }
        } while (createProd== 'S');
        //DataBase bd = new DataBase ();
        DataBase .getPupilsDetails();
    }
        
    }
    Last edited by Jack; 07-02-2007 at 05:18 AM.

  2. #2
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    7

    Default

    Why don't you use collections instead of arrays?
    Is much better than arrays
    try it, if you want I help you

  3. #3
    Ed
    Ed is offline Senior Member
    Join Date
    Jun 2007
    Posts
    110
    Rep Power
    0

    Default

    Your example doesn't work because you never call the "addPupil(pupil) method.
    ;)

Similar Threads

  1. Creating an array of nonprimitive objects
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 08:46 PM
  2. Replies: 1
    Last Post: 03-25-2008, 05:06 AM
  3. Array of Objects
    By bluefloyd8 in forum New To Java
    Replies: 5
    Last Post: 01-22-2008, 06:27 PM
  4. Array with objects
    By toby in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 09:50 AM
  5. Help with Objects!
    By Shorinhio in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 09:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •