cityContactMap.computeIfAbsent(cityName,cityName -> new ArrayList<>()) .add(new AddressBook( last_Name, first_Name, address, cityName, stateName, phone_Number, zip_Code, email )); public void displayCity() { System.out.println("Enter City name \n"); String cityNameFilter = sc.next(); List<Object> objectList = new ArrayList<>(); objectList = stateContactMap.entrySet().stream() .filter(e -> e.getKey().equals(cityNameFilter)) .collect(Collectors.toList()); int num = objectList.size(); System.out.println("List of city objects :"+objectList); } MY output is like this List […]
- Tags '$phone_number', "zip_code": "" }, address, cityContactMap.computeIfAbsent(cityName, cityName, cityName -> new ArrayList()) .add(new AddressBook( last_Name, email )); public void displayCity() { System.out.println("Enter City name \n"); String cityNameFilter = sc.next(); L, First Name :1 Last Name :1 Address :1 City :1 State : 1 Zip_Code :1.0 Phone : 1.0 Email :1]] Trying to iterate over map and play with list o, first_name : '', statename