package com.concretepage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
public class HashMapIntoArrayList {
public static void main(String[] args) {
HashMap<String, String> hmap = new HashMap<>();
hmap.put("One", "One");
hmap.put("Two", "Two");
hmap.put("Three", "Three");
hmap.put("Four", "Four");
Set<Entry<String,String>> ref = hmap.entrySet();
ArrayList<Entry<String, String>> refAgainArrayList = new ArrayList<Entry<String, String>>(ref);
Iterator<Entry<String, String>> refIterator = refAgainArrayList.iterator();
while(refIterator.hasNext()) {
System.out.println("refIterator.next() " + refIterator.next());
}
}
}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
public class HashMapIntoArrayList {
public static void main(String[] args) {
HashMap<String, String> hmap = new HashMap<>();
hmap.put("One", "One");
hmap.put("Two", "Two");
hmap.put("Three", "Three");
hmap.put("Four", "Four");
Set<Entry<String,String>> ref = hmap.entrySet();
ArrayList<Entry<String, String>> refAgainArrayList = new ArrayList<Entry<String, String>>(ref);
Iterator<Entry<String, String>> refIterator = refAgainArrayList.iterator();
while(refIterator.hasNext()) {
System.out.println("refIterator.next() " + refIterator.next());
}
}
}
No comments:
Post a Comment