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. basic example on serialization... its good and cle
View Tutorial          By: Rag at 2012-01-08 02:53:41

2. Hello, I have been using a very similar code on de
View Tutorial          By: Rod at 2011-11-13 15:09:52

3. ma'am aiza teaches us very well.. >< i like
View Tutorial          By: chai at 2011-02-07 07:06:36

4. Like every other Java recursion example, this exam
View Tutorial          By: Uriah at 2010-05-08 18:59:16

5. Interfaces contains all abstract methods(with out
View Tutorial          By: Mahesh at 2012-11-09 06:14:47

6. yaar this example is easy to understand but other
View Tutorial          By: richa at 2009-09-08 13:52:37

7. Hiiii Al, I am Ashraf Abu Aisheh, i am working to
View Tutorial          By: Ashraf Abu Aisheh at 2008-11-09 14:56:39

8. Hi, I tried this code to send sms from my PC which
View Tutorial          By: Jothi at 2009-05-15 03:19:54

9. i thnk exampleThread example is wrong - like billg
View Tutorial          By: oldman at 2011-09-24 12:32:33

10. Great stuff!!!

The clickLink functi

View Tutorial          By: Harro at 2008-10-13 07:25:26