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 7956701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:04:16+00:00 2026-06-04T04:04:16+00:00

I have a key value pair in Hashmap in Java, I am traversing Map

  • 0

I have a key value pair in Hashmap in Java, I am traversing Map in following way.

    ArrayList<String> mysection = new ArrayList<String>();
    ArrayList<String> temp = new ArrayList<String>();

    Iterator it = Map.entrySet().iterator();

    while (it.hasNext()){   
        Map.Entry pairs = (Map.Entry)it.next();                 
        System.out.println(" = " + pairs.getValue());                   

        mysection.add(pairs.getKey().toString());
        temp.add(pairs.getValue().toString());

        it.remove(); // avoids a ConcurrentModificationException        

    }

This seems to be good, but the loop runs one time and creates a long string of value associated with the key. I don’t want in that way. I want each value to be stored in ArrayList but it’s not happening this way. All value is stored in the 1st index itself.

Secondly even if I try to bifurcate I don’t find a suitable way. First I thought of splitting the string via “,” operator but the string itself contains several “,”

Please suggest what should I do specifically for the 1st question, I don’t want the all value as single string.

Thanks

Log:

                                    05-12 12:14:01.387: I/System.out(433): EAMCET: caution on punctuality, 
            05-12 12:14:01.387: I/System.out(433): Delay by even a minute can cost one year for the aspirants, warn the officials making it clear that they need to report at least 45 minutes in advance for the EAMCET to be held on May 12. Th...
            05-12 12:14:01.387: I/System.out(433): , 
            05-12 12:14:01.387: I/System.out(433): Shankar Rao takes on Kiran , 
            05-12 12:14:01.387: I/System.out(433): Former Minister P. Shankar Rao on Friday opened a new front in his fight against Chief Minister N. Kiran Kumar Reddy by submitting a notice of breach of privilege against the latter for preventing...
            05-12 12:14:01.387: I/System.out(433): , 
            05-12 12:14:01.458: I/System.out(433): Police fear more Maoist attacks , 
            05-12 12:14:01.458: I/System.out(433): Uneasy calm prevails in villages tucked away along the shores of the Godavari adjoining neighbouring Chhattisgarh after the Maoists conducted a â??Praja Courtâ? in the interior Mukunur village of Maha...
            05-12 12:14:01.458: I/System.out(433): , 
            05-12 12:14:01.458: I/System.out(433): 'Science in danger of regressing' , 
            05-12 12:14:01.458: I/System.out(433): Askok Ganguly delivers 'A.V. Rama Rao Tech Award Lecture' 
            05-12 12:14:01.458: I/System.out(433): , 
            05-12 12:14:01.458: I/System.out(433): Global firms pick up ISB students , 
            05-12 12:14:01.458: I/System.out(433): Average annual salary offered is Rs.18.83 lakh, 8 p.c. more than last year
            05-12 12:14:01.458: I/System.out(433): , 
            05-12 12:14:01.458: I/System.out(433): Telugu varsity to make its courses job-oriented, 
            05-12 12:14:01.458: I/System.out(433): Potti Sreeramulu Telugu University is planning to attract more students to pursue higher education by offering employment oriented courses.The university was exploring chances to embed info...
            05-12 12:14:01.458: I/System.out(433): , 
            05-12 12:14:01.458: I/System.out(433): Kiran sharpens attack on Jagan, 
            05-12 12:14:01.458: I/System.out(433): Ruling Congress has launched a three-cornered attack on its two arch rivals -- YSRCP president Y.S. Jaganmohan Reddy and TDP chief N. Chandrababu Naidu at Tirupati on Friday in its run up to the b...
            05-12 12:14:01.458: I/System.out(433): , 
            05-12 12:14:01.458: I/System.out(433): RINL to get Central nod soon for mining in Rajasthan, 
            05-12 12:14:01.458: I/System.out(433): The Centre will give its nod soon for granting lease for iron ore mining to Rashtriya Ispat Nigam Limited (RINL), the corporate entity of Visakhapatnam Steel Plant.
            05-12 12:14:01.458: I/System.out(433): â??After the Rajasthan g...

Here is the image of output:
enter image description here

  • 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-04T04:04:18+00:00Added an answer on June 4, 2026 at 4:04 am

    OK, i got it done…actually there are many ways to iterate over maps, this one is not the best suited for what i want. So changed the implentation of iteration of another method now its working smooth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Difference between Map and Properties as both have key-value pair.
suppose you have a HashMap m and there is already a key value pair
I have a hash map table as below, HashMap<String, String> backUpCurency_values = new HashMap<String,
I have a java properties file containing a key/value pair of country names and
Hello if you search in an HashMap<String,String> for a specific value of a key-value-pair,
I have a HashMap where the key is of type String and the value
Is there a way to have the value symbol or key symbol in a
I have a java.util.HashMap object m (a return value from a call to Java
How to remove some key/value pair from SharedPreferences ? I have put and I
I have the following models: # Group for Key/Value pairs class Group(models.Model): name =

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.