Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Iterator loop ... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Iterator loop ..." Watch "Iterator loop ..." New topic
Author

Iterator loop ...

Jack Weavesham
Greenhorn

Joined: Jan 10, 2003
Posts: 6
Hello,
I've tried to write an iteration loop as below:

public void listStudentDetails()
{
Iterator it = students.iterator();
while(it.hasNext()) {
Student students = (Student) it.next();
System.out.println("Name: " + students.getStudentName());
System.out.println("ID: " + students.getIDNumber());
System.out.println("Study Programme: " + students.getStudyProgramme());
System.out.println("Paid fee: " + students.getPaid());
Can anyone say why this doesn't work?
Thanks in advance.
JW
Jon Strayer
Ranch Hand

Joined: Dec 04, 2002
Posts: 133
What are the symptoms?


Jon
Jack Weavesham
Greenhorn

Joined: Jan 10, 2003
Posts: 6
For whatever reason, it compiles okay, but you can't call the method - ideas?
Thanks.
JW
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Jack Weavesham:
For whatever reason, it compiles okay, but you can't call the method - ideas?

What exactly happens when you try to call it?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
And how are you trying to call it from where?


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Originally posted by Jack Weavesham:
For whatever reason, it compiles okay, but you can't call the method - ideas?
Thanks.
JW

I'm sure *I* could call the method, if I new which class it was in ;-)
Seriously though, which method can't you call? What happens when you try? Any details you can give us will help us help you.
Good luck
Layne


Java API Documentation
The Java Tutorial
 
jQuery in Action, 2nd edition
 
subject: Iterator loop ...
 
Similar Threads
Arraylist and for enchanced loop question
Using maps
Iterator with an ArrayList
Method Hash
Exception in thread "main" java.lang.Stack