2

I have an interface with following code

public interface DoSomething {
    public void blah(String s);
}

Next, i have a class which uses this interface as shown below

public class Dummy {
 public static void main(String[] args) {
    //how is the below working when String's equalsIgnoreCase method signature does not match the signature of my interface DoSomething
    String s = "Jim";
    doSomething(s::equalsIgnoreCase, "jim");
  //Again signature mismatch, but code compiles fine
    doSomething(String::toUpperCase, "jim");

 }
 public static void doSomething(DoSomething x, String s) {
    x.blah(s);
 }
}
Jimm
  • 8,165
  • 16
  • 69
  • 118

0 Answers0