Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

looping through a list with an iterator

807597Jun 24 2005 — edited Jun 24 2005
Hi I have a list of objects allCrecords which I want to loop through using an iterator In the method printcoauthors I have to create another instance of class Extractdata because that's where the objects are added to the list allCrecords. The getauthor, getcoauthor and gettitle are methods in the Coauthorship class where this method printcoauthors is also
public void printcoauthors(String currentauthor){
         Extractdata ed = new Extractdata();
    for(Iterator it = ed.allCrecords.iterator();it.hasNext();){
        if(currentauthor.equals(getauthor()))
            System.out.println(getcoauthor());
        else if (currentauthor.equals(getcoauthor()))
            System.out.println(getauthor());
            System.out.println(gettitle()); 
           Object element = (Object)it.next();
       }
    }
thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2005
Added on Jun 24 2005
21 comments
432 views