Created
April 17, 2018 17:33
-
-
Save iamcrypticcoder/afa99b9530ea88aa8e05b4e2cc30d428 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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