What's the difference between instance method reference types in Java 8?

前端 未结 3 1483
感情败类
感情败类 2020-11-27 06:16

So Java 8 introduces method references and the docs describe the four types.

My question is what\'s the difference between the two instance types?

3条回答
  •  爱一瞬间的悲伤
    2020-11-27 06:43

    With this they mean that you have the following:

    1) Can be for example this::someFunction;, this will return the someFunction reference of the current object.

    2) Can be for example String::toUpperCase, this will return the toUpperCase method of String in general.

    I am not sure if there is an actual difference in behaviour, I think it is just like you can also call static methods on instance variables.

提交回复
热议问题