Suppose I have interface A which has only one method declared like below:
interface A{
void print();
}
now with old java style we'll use this in anonymous way like below:
new A() {
@Override
public void print() {
System.out.println("in a print method");
}
};
and with lambda expression we'll use it like below:
() -> "A1";
now my question is if interface A has two methods declared like below:
interface A{
void print();
void display();
}
and its old way of anonymous function utilization is like below:
new A() {
@Override
public void print() {
System.out.println("in print");
}
@Override
public void display() {
System.out.println("in display");
}
};
Now how to convert display method to lambda? or we are not allowed to do this; if not why not? Why cant we represent it like
print() -> "printing"
and
display() -> "displaying"