The method as first-class citizens -Java

                          Methods and Lambda as first-class citizens 

Method references

In Java8 before, if we want to filter hidden files in a directory, we need to do:

    File[] hiddenFiles = new File("").listFiles(new FileFilter() {
        @Override
        public boolean accept(File file) {
            return file.isHidden();
        }
    });

Java8, we can be rewritten as:

File[] hiddenFiles2 = new File("").listFiles(File::isHidden);

:: This syntax means that this method as the value passed to listFiles method.

 

 

 

 

(When I read "Java8 combat" to write it, although I have a basic understanding of the properties of Java 8 but because of less use, so it can not be mastered, which is about a week after the estimated 2020 January 5th, of course, not necessarily, the recent plan to learn about the database and the underlying operating system to complete literacy, basic project off the stage, and may learn to catch fish, and this is no way of things, after all, time is running out, I would estimate at 2-3 months later for work, although I have not much interest in the framework, but how they have to come up with a month's time to learn and to do items hot hand)

Guess you like

Origin www.cnblogs.com/CherryTab/p/12116367.html