Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 616197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:18:03+00:00 2026-05-13T18:18:03+00:00

ArrayList array = new ArrayList(); Iterator it1 = array.iterator(); while (it1.hasNext()){ Myclass temp =

  • 0
ArrayList array = new ArrayList();

Iterator it1 = array.iterator();
while (it1.hasNext()){
   Myclass temp = it1.myGetterMethod();
   System.out.println (temp);
}

This is what I would like to implement, but Iterator only returns a generic Object. When I call Object.getClass(), the class is Myclass. Does this mean that the Iterator is not generic, and I need extend the Iterator class whenever I’m iterating objects that aren’t Java strings etc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:18:03+00:00Added an answer on May 13, 2026 at 6:18 pm

    You did not create a generic ArrayList.

    Try

    ArrayList<MyClass> array = new ArrayList<MyClass>();
    
    Iterator<MyClass> it1 = array.iterator(); 
    while (it1.hasNext())
    { 
        MyClass temp = it1.myGetterMethod(); 
        System.out.println (temp); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

String a []= {null,null,null,null,null}; //add array to arraylist ArrayList<Object> choice = new ArrayList<Object>(Arrays.asList(a)); System.out.println(choice.size());
int[] arrc = new int[] {1, 2, 3}; System.out.println(new ArrayList(Arrays.asList(arrc))); prints address, but i
System.out.println(ganzeZeile[26]); System.out.println(filter.get(11)); System.out.println(ganzeZeile[26].contains(filter.get(11))); ganzeZeile is an array of Strings. filter is an ArrayList of
I need to serialize ArrayList<String> arr=new ArrayList<String>(); on server and then send this array
I have the following array ArrayList<double[]> db_results = new ArrayList<double[]>(); and I would like
I have developed a array list something like this ArrayList<String> list = new ArrayList<String>();
I want to have an array of ArrayLists: ArrayList<MyClass>[] myArray; I want to initialize
I have an array of strings. How can I convert it to System.Collections.ArrayList?
I have an array list of objects in my application. private static ArrayList<Player> userList=new
I'm working with two-dimensional array-values that should be inserted into a ArrayList. But this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.