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. To make this work with out error I had to add:
View Tutorial          By: Jester at 2009-03-26 15:25:59

2. This is very much useful to me to complete my assi
View Tutorial          By: Eva Jhonson at 2012-09-30 16:44:08

3. Hi Binod,

Since JSP code is execute

View Tutorial          By: Aathi at 2009-05-28 21:20:10

4. can anybody tell me the full code for sending sms
View Tutorial          By: shikha at 2008-10-13 11:43:40

5. Hy gr8 man..!!! It was easy understanding
View Tutorial          By: ahwe at 2010-04-07 02:50:40

6. Thank you very much for your help,
this co

View Tutorial          By: AA at 2011-09-09 14:24:45

7. Been hearing about this for quite long. This gives
View Tutorial          By: Lolip at 2011-08-24 08:40:20

8. nice info 4me
View Tutorial          By: baru at 2015-07-24 08:52:03

9. help me for this nested for loops
2 3 4 5
View Tutorial          By: nadzirah at 2012-10-12 15:33:20

10. pls send more tutorial on my id
View Tutorial          By: vipin at 2012-11-17 07:23:49