Why is it that String's toUpperCase is not a static method, but can be called by String::toUpperCase?

Why is it that the toUpperCase of String is not a static method, but can be called by String::toUpperCase?

    List<String> myList =
            Arrays.asList("a1", "a2", "b1", "c2", "c1");
    myList
         .stream()
         .filter(s -> s.startsWith("c"))
         .map(String::toUpperCase)
         .sorted()
         .forEach(System.out::println);

tutorials on the Internet
clipboard.png

Mar.14,2021

refer to java documentation: Method References

roughly means that java calls the method with the first parameter passed to it as an instance.

clipboard.png

clipboard.png

Menu