Posts

Showing posts with the label Method references

Java 8 - Lambda expressions (Introduction and purpose) with examples

Hi, I am Malathi Boggavarapu working at Volvo Group and i live in Gothenburg, Sweden. I have been working on Java since several years and had vast experience and knowledge across various technologies. This post teach you about Java 8 - Lambda expressions using some practical examples Introduction to Lambda expressions To understand it easily, lets start with FileFilter example. public interface Filefilter{     boolean  accept(File file); } public class JavaFileFilter implements FileFilter{     boolean accept(File file){          return file.getName().endsWith(".java")    } } JavaFileFilter fileFilter = new JavaFileFilter(); File dir = new File("d:/tmp"); File[] files = dir.listFiles(fileFilter); 2) FileFilter fileFilter = new FileFilter(){       boolean accept(File file){          file.getName().endsWith(".java");      } }; ...