Java Reference
In-Depth Information
public Item() {
System.out.println("Constructor Item() called.");
}
public Item(String name) {
this.name = name;
System.out.println("Constructor Item(String) called.");
}
public Item(String name, double price) {
this.name = name;
this.price = price;
System.out.println("Constructor Item(String, double) called.");
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setPrice(double price) {
this.price = price;
}
@Override
public double getPrice() {
return price;
}
@Override
public String toString() {
return "name = " + getName() + ", price = " + getPrice();
}
public void test() {
// Uses the Item.toString() method
Supplier<String> s1 = this::toString;
// Uses Object.toString() method
Supplier<String> s2 = Item.super::toString;
// Uses Item.getPrice() method
Supplier<Double> s3 = this::getPrice;
// Uses Priced.getPrice() method
Supplier<Double> s4 = Priced.super::getPrice;
Search WWH ::




Custom Search