Home > Java > javaTutorial > body text

How to reference the four methods in java8

WBOY
Release: 2023-04-25 10:10:06
forward
1218 people have browsed it

1. Constructor method reference

Test test = Test.create(Test::new);
Copy after login

2. Static method reference

test.operate(1, 2, Test::add);
Copy after login

3. Object instance Method reference

test.operate(1, 2, test::sub);
Copy after login

4. Instance method reference of the class, satisfies the instance method first, not the static method.

The first parameter of the Lambda expression will become the object of the calling instance.

test.test(Test::testM);
Copy after login

What collection classes are there in Java?

Collections in Java are mainly divided into four categories:

1. List: ordered, repeatable;

2. Queue: ordered and repeatable;

3. Set: non-repeatable;

4. Map: unordered, with unique keys and non-unique values.

The above is the detailed content of How to reference the four methods in java8. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template