Link Details

Link 1108819 thumbnail
User 1221175 avatar

By Bharatbsharma
via dzone.com
Published: Feb 12 2014 / 10:10

JavaSoft people wanted to add some new features as part of java 7.0 version . To know which Features to be added , they reviewed the feed back from software developers who suggested a list of features to be added into java. This project of reviewing and adding new features is called "Project Coin" . Some features discussed below . 1) Using String in Switch statement Up to Java 7.0 there is no way of using strings in switch statement . We can use only byte, short, int or char types in the switch statement . But starting from java 7.0 on wards , it is permitted to use string inside a switch statement to decide the course of action inside the switch block. /* This code is invalid up to Java 7.0 but valid from Java 7.0 onwards */ String day="Mon"; switch(day) { case "Mon" : System.out.println("Monday"); break; case "Tue" : System.out.println("Tuesday"); break; } 2) Binary literals with prefix 0B A literal represents a value which is stored into a variable in a program. For example , int num= 78; Here, 78 is called an integer type literal since it is stored into int type variable num. Suppose, we want to store octal values, we can write that literal with a prefix '0' and hexadecimal values with a prefix '0x' , as shown in the following code: int num= 078; //this is octal value int num=0x78; //this is hexadecimal values From java 7.0 onwards, it is possible to create binary literals which can be represented with a prefix 0b or 0B, as : int num=0b1101; // this is binary value short num=(short)0b1101; // binary value is converted into short 3) Introduction of Underscore in Numeric Literals To improve the readability , underscore( _ ) is introduced in the numeric literals . It is possible to use several underscore in a binary number, integer, float or double numbers. int a=0B1010_1100_0110; int num=10_00_000; 4) Catching Multiple Exceptions Before Java 7.0 we should write multiple catch blocks to each several exception . In Java 7.0 we can catch more than one exception in the same catch block using or symbol ( | ). For example , instead of writing two block , we can write a single catch block in the above program as : catch(NegativeArraySizeException | NumberFormatException obj) { System.out.println(obj); ...... ....... } Java 8 is expected on 18 March 2014 and will include some features that were planned for Java 7 but later deferred.
  • 6
  • 9
  • 1099
  • 1623

Comments

Add your comment
User 776377 avatar

lburnham123 replied ago:

2 votes Vote down Vote up Reply

"New" features? Java 7 came out in 2011. And the name "JavaSoft" became extinct in 2010 with the demise of Sun. Well, at least we're spared the rest of article since the link is wrong.

User 275157 avatar

jpox1 replied ago:

2 votes Vote down Vote up Reply

FFS the "link" URL (for text "New Features of Java 7" above) is the add link page of DZone. Perhaps those who upvoted this do random upvoting without actually reading? Says much about the state of stuff on here

User 187417 avatar

sproketboy replied ago:

2 votes Vote down Vote up Reply

How did this garbage get any upvotes? Are Bharatbsharma, arjan_tijms, dp619, esrikis, mswatcher and priyakant retarded or something? Well I know mswatcher is but not sure of the others.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java