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. thanks Mr Ramlak
i m using samsung j600 mob

View Tutorial          By: yash at 2008-05-13 15:05:49

2. what are the required equipments to run j2me
View Tutorial          By: messi at 2012-11-13 13:15:18

3. Hi professional,
I tried the above code but

View Tutorial          By: Srinivas at 2008-05-05 23:32:13

4. Been looking at several website for a clear explan
View Tutorial          By: Jase at 2011-08-09 12:00:10

5. hai,
i want to know how the connect

View Tutorial          By: V.Selvi at 2010-02-28 21:01:33

6. just remember to add
<uses-permission an

View Tutorial          By: Mouad at 2013-07-22 10:47:27

7. i always encounter a problem every time we discuss
View Tutorial          By: sukira 18 at 2009-08-29 03:25:23

8. I don't think GSM/Modem simulatur, will get it wor
View Tutorial          By: Michael Chon at 2008-10-08 10:35:55

9. Write a program to input the number and use switch
View Tutorial          By: abdulaziz at 2014-03-28 16:22:35

10. I have a small query: Is it interface allow method
View Tutorial          By: vijay at 2012-04-20 10:34:30