Content-Length: 1928 | pFad | https://github.com/jake1412/Java-Programming/raw/refs/heads/main/FAT-Practice/src/MapsPractice.java

th: 1916 import java.util.*; public class MapsPractice { public static void main(String[] args) { HashMap> h1 = new LinkedHashMap<>(); HashMap h2 = new LinkedHashMap<>(); // Check if HashMap is empty System.out.println("is studentsMapping empty?: " + h1.isEmpty()); System.out.println("is studentsMapping empty?: " + h2.isEmpty()); // creating list of subjects and adding to hash map List subjects = Arrays.asList("Python", "Math", "C"); h1.put("A", subjects); subjects = Arrays.asList("C", "C++"); h1.put("B", subjects); subjects = Arrays.asList("C++", "Physics", "Chemistry"); h1.put("C", subjects); // creating hashmap of faculty h2.put("Python", "111"); h2.put("Math", "222"); h2.put("C", "333"); h2.put("C++", "444"); // displaying all students and subjects for (Map.Entry m : h1.entrySet()) { System.out.println(m.getKey()); subjects = (List) m.getValue(); for (String s : subjects) System.out.print(s + " "); System.out.println(); } // displaying all subjects and faculty for (Map.Entry m : h2.entrySet()) { System.out.println(m.getKey() + " " + m.getValue()); } // Scanner sc = new Scanner(System.in); // System.out.print("Enter a student: "); String s = "B"; System.out.println("Faculties are: "); for (Map.Entry m : h1.entrySet()) { if (m.getKey().equals(s)) { for (Map.Entry m2 : h2.entrySet()) { subjects = (List) m.getValue(); if (subjects.contains(m2.getKey())) System.out.println(m2.getValue()); } } } } }








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/jake1412/Java-Programming/raw/refs/heads/main/FAT-Practice/src/MapsPractice.java

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy