Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public class CountryTest {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. Country countryObj1 = new Country("Japan", "Tokyo", 126440000);
  6. Country countryObj2 = new Country("Czech Republic", "Prague", 10610947);
  7. Country countryObj3 = new Country("Canada", "Ottawa", 37412852);
  8.  
  9. List<Country> countryList = new ArrayList<>();
  10.  
  11. countryList.add(countryObj1);
  12. countryList.add(countryObj2);
  13. countryList.add(countryObj3);
  14.  
  15. CountryHelper countryHelper = new CountryHelper();
  16.  
  17. // approach 1:
  18. List<Country> countryNamesList = countryHelper.getCountryNameStartsWithC(countryList);
  19. List<Country> countryPopulationList = countryHelper.getCountryPopulationMoreThan100Million(countryList);
  20.  
  21. for(Country country : countryNamesList) {
  22. System.out.printf("Country Names Starts With Letter C: %s \n", country);
  23. }
  24.  
  25. for(Country country : countryPopulationList) {
  26. System.out.printf("Country Names MORE Than 100 Million %s \n", country);
  27. }
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement