Results 1 to 3 of 3

Thread: Printing out in main

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2008
    Posts
    87

    Printing out in main

    I have this code to print all elements out in an array

    public void printChildren(ArrayList<Person> child){

    for (int i = 0 ; i < child.size(); i++)
    System.out.println( child.get(i).getName() + " " + child.get(i).getAge());



    }
    }

    But I cant really make it work in the main.... trying to call it but I only get error.. so how can I call it or print it from the main

    thanks

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Printing out in main

    What error are you getting?
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: Printing out in main

    if you add static keyword to your function declaration of printChildren, then you'll be able to call this function from main.

    hope this helps.

Posting Permissions

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



Click Here to Expand Forum to Full Width