Junior — Senior
Output city names from the list to the console
livecode
Task condition
In the main method, add code that prints the names of all City objects stored in the cities collection.
import java.util.*;
import java.util.stream.*;
public class Main {
public static void main(String[] args) {
List<City> cities = getCity();
// Add code here
}
private static List<City> getCity() {
return List.of(
new City("msk"),
new City("msk"),
new City("spb"),
new City("ekb")
);
}
}
public class City {
private String name;
public City(String name) {
this.name = name;
}
public String getName() {
return name;
}
}