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 article is very clear,short and direct to the
View Tutorial          By: N JIBRIN at 2007-03-15 11:48:26

2. Hi every one. I am working on my project in j2me a
View Tutorial          By: wazir at 2010-11-26 08:27:43

3. thanks a lot..please tell me how to implement this
View Tutorial          By: agnas at 2008-04-26 12:26:52

4. introduction is very clear i get wat answer i want
View Tutorial          By: kalyan at 2013-07-02 09:23:40

5. Hello Nishi,
The class names in your progra

View Tutorial          By: Kiran at 2011-12-16 06:32:54

6. HI,
I am getting this error
Error lo

View Tutorial          By: vijay bhanu at 2009-07-18 08:57:57

7. hey i need a sms recieving code....
View Tutorial          By: Kishore at 2009-08-06 09:11:13

8. hi! im new in j2me applications so i just cleaned
View Tutorial          By: resego at 2010-08-04 07:29:29

9. i want daily tutorials
View Tutorial          By: ashish at 2007-12-18 04:26:19

10. you can use multiple switch statements depending o
View Tutorial          By: moshood at 2012-04-01 13:24:41