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

  • SEARCH
  • Home
  • 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 9130177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:54:46+00:00 2026-06-17T07:54:46+00:00

I have a TreeMap defined like: final TreeMap<ArrayList<String>,String> mymap = new TreeMap<ArrayList<String>,String>(comparator); When I

  • 0

I have a TreeMap defined like:

final TreeMap<ArrayList<String>,String> mymap = new TreeMap<ArrayList<String>,String>(comparator);

When I try to iterate over it like this:

Iterator iter = (Iterator) mymap.entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry entry = (Map.Entry) iter.next();
    }

I am getting error message like The method hasNext() is undefined for the type ObjToIntMap.Iterator on the 2nd line and Multiple markers at this line
– Map.Entry is a raw type. References to generic type Map.Entry should be
parameterized
on the 3rd line.

What is the source of this error, and how can I fix it?

  • 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-06-17T07:54:47+00:00Added an answer on June 17, 2026 at 7:54 am

    Maybe you imported the wrong Iterator class? Are you sure you have imported java.util.Iterator and no other class from an other package that is also named Iterator?

    If you imported the correct Iterator class you can remove the typecast and add the generic type to the iterator:

    Iterator<Map.Entry<ArrayList<String>, String>> iter = mymap.entrySet().iterator()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TreeMap resMap new TreeMap<String, Map<String, String>>(); I would like to filter
I have a Map[Long, String] which I would like iterate over in descending order
I have a TreeMap that holds the following keys/values: private ArrayList<TreeMap<String,String>> mList = new
I have a treemap containing occurrence of words like this ... TreeMap <String,Integer> occurrence
I have created a TreeMap like so: TreeMap<Integer, ArrayList<MyClass>> wrap = new TreeMap<Integer, ArrayList<MyClass>>();
I have this method: private SortedMap<String, SpaceObjectImpl> catalog = new TreeMap<String, SpaceObjectImpl>(); public Collection<SpaceObject>
I have the following TreeMap: TreeMap<String, Integer> distances = new TreeMap<String, Integer>(); and it
If I have following map: NavigableMap<Integer,String> nmap = new TreeMap<Integer,String>(); nmap.put(3, Three); nmap.put(1, One);
Ok I have this code: TreeMap<DateTime, Integer> tree2 = getDatesTreeMap(); DateTime startx = new
Suppose I have import scala.collection.immutable.TreeMap val tree = new TreeMap[String, List[String]] Now after above

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.