Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class SortPairs {
- private static int physical = 0;
- private static int words = 0;
- public static void main(String[] args) {
- // map to store
- Map<String, List<String>> map = new LinkedHashMap<String, List<String>>();
- // create list one and two and store mixed
- List<String> words1 = new ArrayList<String>();
- List<String> physical1 = new ArrayList<String>();
- physical1.add("ph1");
- words1.add("wor1");
- physical1.add("ph2");
- words1.add("wor2");
- physical1.add("ph3");
- words1.add("wor3");
- physical1.add("ph4");
- map.put("A", words1);
- map.put("B", physical1);
- ArrayList<List<String>> list = new ArrayList<>();
- // iterate and display values
- System.out.println("Fetching multiple keys and corresponding values: ");
- for (Map.Entry<String, List<String>> entry : map.entrySet()) {
- String key = entry.getKey();
- List<String> values = entry.getValue();
- list.add(values);
- }
- int j = 0;
- while ( j < list.get(0).size() ) {
- int i = 0;
- while ( i < list.size() ) {
- System.out.println( list.get(i).get(j) );
- i++;
- }
- j++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement