What is new features of the java 1.7 .






                                                     


1.Diamond Operator

2.  Using strings in switch statement


3.  Automatic resource management

4.  Numeric literals with underscore

5.  Improved Exception Handling

6.  New File System API (NIO 2.0)

7.  Fork and Join





1.Diamond  Operator :—




         Set  < Object , Object > = new   HashSet<Object , Object >() ;


     repetition  of  generics  both side   up  to  java  1.6 .   Using    java 1.7   we can  declare 
        
          same     HashSet Like 


                  Set  < Object , Object > = new   HashSet< >() ;



2.String  For  The  Switch  Statement :


Java  1.6   and   earlier  version  used  int values (convertible) , enum's as contestants of switch cases.  But  java 1.7   java.lang.String  can be use as  contestants



 String caseContestant= "Apple";

  switch(caseContestant){ t

  case  "Apple" :
  System.out.print("I am apple");

     break;
  case  "Mango" :
     System.out.print("I am mango");
     break;
}

3. Automatic   Resource Management :—

  Java  1.7  introduced     java.lang.AutoCloseable      interface .  Which  having  method   called void close() throws Exception  .  This  method  is completely use   to manage the  resources .  

   Java 1.7   the  resources  are manage  automatically  by the  JVM . 



4.  Numeric  Literals  With  Underscore : 

 In   Java 1.7   we  can declare the  like  

  int   value   =   9_000  ;   


5. Improved  Exception Handling :


  In   Java 1.7   you  can  declare multi   exceptions  in the single catch .  This look like  this 
try{



    }catch(Exception1 |  Exception 2 | Excception 3 | Exception 4   exceptionObject){

         your code;
    }


6. New File  System  NIO:

 Java  1.7  system  change  java.io.* ;  to    java.nio.*;   which  is    has  different   features  from the
 old  IO   package  .  NIO   stands  for  New  Input Output . 


   Here  are  some   important   operations  of the  NIO . 


        A. classes supporting   file   operation 

         B.  File Operations and File DataOperations 
        
        C.  Specific Objects 

        D.  Path  and File System Representation  


7.   Fork  and Join 

This is a mechanism through which you make the best use of the processors available in your systems .


Step 1:


ForkJoinPool   pool = new ForkJoinPool(Runtime.getRunTime().availableProcessors())

The first step informs the master (ForkJoinPool) , the number of processors available in the system for it to manage with .

Step 2:

pool.invoke(task);

Here you will give the task you want to be executed to the ForkJoinPool ,and it will take care of delegating this work to the free processor.





What is new features of the java 1.7 . What  is new features  of the java 1.7 . Reviewed by Mukesh Jha on 12:36 AM Rating: 5

No comments:

Add your comment

All Right Reserved To Mukesh Jha.. Theme images by Jason Morrow. Powered by Blogger.