Skip to content

Instantly share code, notes, and snippets.

@HDBandit
Last active December 15, 2015 19:03
Show Gist options
  • Save HDBandit/704485f4a7f9b1792dec to your computer and use it in GitHub Desktop.
Save HDBandit/704485f4a7f9b1792dec to your computer and use it in GitHub Desktop.
// business logic
public static List<Car> filterCarsByBrand(List<Car> cars, String brand) {
ArrayList<Car> filteredCars = new ArrayList<Car>();
for (Car car : cars) {
if (brand.equals(car.getBrand())) {
filteredCars.add(car);
}
}
return filteredCars;
}
...
// from your programm, you can call it from this way
List<Car> filteredCars = filterCarsByBrand(cars, "Ferrari");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment