Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: System.out.println Error when using Iterator

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default System.out.println Error when using Iterator

    Hi Guys

    Im new to programming and Java, but im willing to learn and trying hard using a book `Objects first with Java`.
    Im trying to create a program for a Library where Members can join and loan books. But i keep getting an Error when using the Iterator.
    My code is below:

    import java.util.ArrayList;
    import java.util.Iterator;
    /**
     * Write a description of class Library here.
     * 
     * @author (your name) 
     * @version (a version number or a date)
     */
    public class Library
    {
        private ArrayList<Book> books;
        private ArrayList<Member> members;
        private int nextMemberNumber;
     
        /**
         * Constructor for objects of class Library
         */
        public Library()
        {
            books = new ArrayList<Book>();
            members = new ArrayList<Member>();
            nextMemberNumber = 1;
        } 
        public void AddNewMember( Member newMember )
        {
          members.add(newMember);
          nextMemberNumber++;
        }
        public int NumberOfMembers()
        {
            return members.size();
        }
        public void ShowMembers( String getDetails )
        {
            Iterator<Member> it = members.iterator();
            while(it.hasNext())
            {
                Member t = it.next();
                System.out.println(t.getMember());// --------------------This is where the error is when i complie. getMmember?
            }
        }
        public int numberOfMembers()
        {
            return members.size();
        }
        }

    Any help would be great, i can see people really know what there talking about on here thats why i joined. Thanks Guys

    Willo
    Last edited by jps; December 3rd, 2012 at 04:25 PM. Reason: Added code tags


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,128
    My Mood
    Cynical
    Thanks
    64
    Thanked 138 Times in 133 Posts

    Default Re: System.out.println Error when using Iterator

    Can you show us the error message?

Similar Threads

  1. System.out.println Not Working
    By manjula in forum JavaServer Pages: JSP & JSTL
    Replies: 6
    Last Post: November 27th, 2012, 06:25 AM
  2. use of System.out.println(""); error....
    By rohan22 in forum Java Theory & Questions
    Replies: 2
    Last Post: July 16th, 2011, 10:49 AM
  3. How to modify System.out.println()
    By emailkia in forum Java Theory & Questions
    Replies: 6
    Last Post: April 25th, 2011, 12:40 AM
  4. what is System,out,println in System.out.println()?
    By koteshk in forum Java Theory & Questions
    Replies: 2
    Last Post: April 18th, 2011, 12:28 AM
  5. How can i print rows 1 by 1 using System.out.println?
    By noFear in forum Java Theory & Questions
    Replies: 2
    Last Post: August 26th, 2010, 07:35 AM

Tags for this Thread