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:

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.