Friday, June 22, 2018

Java 8 - Features - Important info


Java 8



  1. forEach() method in Iterable interface
  2. default and static methods in Interfaces
  3. Functional Interfaces and Lambda Expressions
  4. Java Stream API for Bulk Data Operations on Collections
  5. Java Time API
  6. Collection API improvements
  7. Concurrency API improvements
  8. Java IO improvements
  9. Miscellaneous Core API improvements

It will be good if  having knowledge on below areas :

1)   Basic Java programming

2)  Basic knowledge of the main APIs

3)  Generics

4)  Collection API

5)  I/O



Important  topics/features in Java 8


1)  The most useful new parts of Java 8


2)  Lambda expressions

                 To make instances of anonymous classes easier to write  and read!


                      Introduction to the <<Lambda expressions >>
                      The lambda syntax
                      Functional interfaces.
                      Method references
                       Construction references.


                        A simple example



                Interface :

                       public interface FileFilter {

                                  boolean  accept(File file);
                        }

              Implementation class :
             
            public  class JavaFileFilter implements FileFilter  {

                        public boolean  accept(File file) {

                            return   file.getName().endsWith(".java");
                        }
              }


                        


                       
              Use it  as :

              JavaFileFilter  fileFilter = new JavaFileFilter();
                 File dir  = new file("d:/tmp");
                 File[] javaFiles = dir.listFiles(fileFilter);



               Also let's use an anonymous class :


                  FileFilter  fileFilter  = new  FileFilter()  {

                                  @Override

                              public boolean accept (File file)  {

                                 return file.getName().endsWith(".java");
                                }
                    };


                File dir = new  File("d:/tmp");
                File[]  javaFiles = dir.listFiles(fileFilter);



                           
    Let's write above code in Lambda expressions :

                    
                                             FileFilter filter  =(File file)  ->  file.getName().endsWith(".java");


                        






3)  The Stream API  and Collectors.


4)   And many bits and pieces.


5)   Java FX



6)  Nashorn

        New script engine.

No comments:

Post a Comment

Hyderabad Trip - Best Places to visit

 Best Places to Visit  in Hyderabad 1.        1. Golconda Fort Maps Link :   https://www.google.com/maps/dir/Aparna+Serene+Park,+Masj...