I assume you want to search in your AirbnbListing list. You can use Java Stream. Use the filter
method for that:
List<AirbnbListing> matchingListings = listings.stream()
.filter(l -> "Surrey".equals(l.getCity()))
.collect(Collectors.toList());
If you want a list of all cities, you can use the map
method:
List<String> matchingListings = listings.stream()
.map(l -> l.getCity())
.collect(Collectors.toList());
Additionally here is an official Java stream explanation tutorial.
2
solved Return specific object from an ArrayList