Skip to content

Instantly share code, notes, and snippets.

@iamcrypticcoder
Created April 17, 2018 17:33
Show Gist options
  • Save iamcrypticcoder/afa99b9530ea88aa8e05b4e2cc30d428 to your computer and use it in GitHub Desktop.
Save iamcrypticcoder/afa99b9530ea88aa8e05b4e2cc30d428 to your computer and use it in GitHub Desktop.
public class SupplierDemo {
static class Car {
String brand;
int engineCC;
int wheelCount;
int price;
public Car(String brand, int engineCC, int wheelCount, int price) {
this.brand = brand;
this.engineCC = engineCC;
this.wheelCount = wheelCount;
this.price = price;
}
@Override
public String toString() {
return "Car{" +
"brand='" + brand + '\'' +
", engineCC=" + engineCC +
", wheelCount=" + wheelCount +
", price=" + price +
'}';
}
}
public static void main(String... args) {
Supplier<Car> fordCarProvider = () -> new Car("Ford", 1500, 4, 43000);
Supplier<Car> bmwCarProvider = () -> new Car("BMW", 1500, 4, 83000);
System.out.println(fordCarProvider.get());
System.out.println(bmwCarProvider.get());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment