Java 7 awesome Features

Java (programming language)
Image via Wikipedia

Whenever, I am crawl through the web i notice the word java 7.Then,I really found out java 7 is today’s hot topic. So i googled it for know something about java 7.At that time i found out some thing interested and useful features in java 7.Thats push me here to share something to you all folks.Lets get into the topic.

The project name of java 7 development is Project Coin.I have listed some of the features below.

Null-safe Method invocation:

This is the greatest feature which is going to added in Java 7.NullPoniterException is one of the most common exception encountered in Java programming.

When I searched “NullPointerException” in Google, it gave about 5,570,000 results! This proves how pervasive the exception is and how much effort a developer has to put in writing java code free from null pointer exception.

Suppose if java has a feature to keep us in safe zone from null pointer exception, how is it? It happens.

Suppose we have a method to fetch postal code of a person’s address:

01 public String getPostcode(Person person)
02 {
03 if (person != null)
04 {
05 Address address = person.getAddress();
06 if (address != null)
07 {
08 return address.getPostcode();
09 }}
10 return null;
11 }

Now check the above syntax. We have done lots of if (null! = object) checks to avoid NullPointerException.

1 public String getPostcode(Person person)
2 {
3 return person?.getAddress()?.getPostcode();
4 }

Null-ignore invocation is concerned with dealing with possible null values in calling one or especially a chain of methods. Check the syntax?. while calling method on an object. This is Null-safe operator in Java 7. Thus, you can avoid lots of if (null!= object) checks in Java 7.

Strings in Switch Statements:

Whenever i am working with switch-case i felt, if the case allowed the string as a case variable we feel so comfort on that. Because the switch case allows only the primitive data types as variable such as integer, char etc.

Whenever i working with the methods that returns status of the operations like succesful, failed like that. At that time i need to convert that in to constants. Then only i can move on switch statements.

But java 7 offers the Strings as case variables in Switch Statements, So we are free from the conversion process.

Multi-Exception Catch:

 

Another awesome update is Multi-Exception Catch, that means a single catch can handle multiple exceptions. The syntax is

1 try
2 {
3 block of statments
4 }
5 catch(Exception1|Exception2|Exception3...)
6 {
7 block of statements.
8 }

It save lot of spaces in the code.

Bracket Notation for Collections:

This feature refers to the ability to reference a particular item in a Collection with square brackets similar to how Arrays are accessed. Collection is one of the key concepts in java.

But when i was a student, I feel so discomfort with collections because of its strutcture.Thats some thing different from basic things in java.

But now its also be like a simple things like array etc. For ex, a Collection class we might consider something similar to arrays.

Instead of:

1 Collection<String> c = new ArrayList();
2 c.add(“one”);
3 c.add(“two”);
4 c.add(“three”);
5 Use:
6 Collection<String> c = new ArrayList {“one”, “two”, “three” };

Thats all folks.If any important updates are missing don’t hesitate to add that as comments

Metoojava's Blog

Whenever, I am crawl through the web i notice the word java 7.Then,I really found out java 7 is today’s hot topic. So i googled it for know something about java 7.At that time i found out some thing interested and useful features in java 7.Thats push me here to share something to you all folks.Lets get into the topic.

The project name of java 7 development is Project Coin.I have listed some of the features below.

Null-safe Method invocation:

This is the greatest feature which is going to added in Java 7.NullPoniterException is one of the most common exception encountered in Java programming.

When I searched “NullPointerException” in Google, it gave about 5,570,000 results! This proves how pervasive the exception is and how much effort a developer has to put in writing java code free from null pointer exception.

Suppose if java has a feature to keep us in…

View original post 320 more words

22 thoughts on “Java 7 awesome Features

  1. I believe this web site has got some very great info for everyone. “There is nothing so disagreeable, that a patient mind cannot find some solace for it.” by Lucius Annaeus Seneca.

    Like

  2. Merely a smiling visitor here to share the love (:, btw outstanding style. “He profits most who serves best.” by Arthur F. Sheldon.

    Like

  3. Only wanna input on few general things, The website pattern is perfect, the content material is really excellent : D.

    Like

  4. I don’t even know how I stopped up here, but I thought this put up used to be great. I do not understand who you might be but definitely you are going to a well-known blogger in the event you aren’t already 😉 Cheers!

    Like

  5. Thankyou for all your efforts that you have put in this. very interesting information. “Illegitimacy is something we should talk about in terms of not having it.” by Dan Quayle.

    Like

  6. Woah! I’m really enjoying the template/theme of this blog. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appearance. I must say you’ve done a great job with this. Additionally, the blog loads extremely quick for me on Safari. Superb Blog!

    Like

  7. Heya i am for the first time here. I found this board and I find It really helpful & it helped me out much. I am hoping to provide one thing back and aid others such as you helped me.

    Like

  8. Just wanna state that this is handy , Thanks for taking your time to write this. “A sailor without a destination cannot hope for a favorable wind.” by Leon Tec.

    Like

  9. Care for the land is the hallmark of a peaceful society. Well, that is what’s happening today on this website.

    Like

  10. Hello there! Would you mind if I share your blog with my facebook group? There’s a lot of people that I think would really appreciate your content. Please let me know. Many thanks

    Like

  11. I really appreciate this post. I’ve been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thank you again! “That which does not kill us makes us stronger.” by Friedrich Nietzsche.

    Like

  12. I used to be in search of this web site last three days good weblog proprietor wonderful posts every little thing is great

    Like

  13. I like this web blog its a master peace ! Glad I discovered this on google. “Tears are the rinse water of an unhappy heart.” by Raynor Schein.

    Like

  14. Hmm it seems like your site ate my first comment (it was super long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I too am an aspiring blog blogger but I’m still new to the whole thing. Do you have any points for rookie blog writers? I’d genuinely appreciate it.

    Like

  15. Hiya, I am really glad I’ve found this information. Today bloggers publish only about gossips and web and this is really irritating. A good web site with exciting content, this is what I need. Thank you for keeping this website, I’ll be visiting it. Do you do newsletters? Cant find it.

    Like

  16. My brother suggested I would possibly like this blog. He used to be totally right. This put up actually made my day. You cann’t imagine simply how a lot time I had spent for this info! Thanks!

    Like

  17. Keep up the wonderful piece of work, I read few posts on this web site and I believe that your website is really interesting and has bands of great info.

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.