Comment on Tutorial - How to use Iterator in Java By Fazal



Comment Added by : Steve

Comment Added at : 2012-01-18 15:58:31

Comment on Tutorial : How to use Iterator in Java By Fazal
I would like to know how to obtain the object that the Iterator is actually referencing. Not all ArrayLists will be storing Strings, and no matter what I do I cannot obtain the object being referenced by that iterator.

For example, if my ArrayList is storing MyClass objects I want to do something like this:

Iterator iter = theArrayList.iterator();
MyClass current = (MyClass)iter; // <--- What do I do here?


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. This is a great article that deals with the evolut
View Tutorial          By: JPS SASTRY at 2009-02-11 21:29:56

2. This code rocks!! any one having any trouble shoul
View Tutorial          By: Ankur at 2010-01-22 06:37:10

3. Thanks a lot!!!

Its very useful exp

View Tutorial          By: dipali at 2012-12-31 06:49:41

4. comm.jar file for windows not available in sun. ca
View Tutorial          By: borus at 2015-03-25 07:19:57

5. Sir, can i execute the program from windows enviro
View Tutorial          By: krishna at 2014-04-08 07:05:30

6. superb superb maza aggaya maza aggaya
View Tutorial          By: pramodh at 2012-04-16 05:21:54

7. Good start for me. At least I now know what i am s
View Tutorial          By: eoaddai at 2011-12-23 20:53:35

8. The above code works for me. When I run the progra
View Tutorial          By: Avinash at 2011-12-01 10:20:19

9. THANX FOR THE INFO....
View Tutorial          By: Abhinaykumar at 2010-07-06 11:34:53

10. Before i had lot of doubts in abstract class... no
View Tutorial          By: Mohandoss at 2012-04-02 05:08:43