• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what is your favorite java 7 feature?

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We've done favorites before, but it would be fun to do again since we have guest authors here.

Mine is autoclosing resources.

I learned while reading "Java 7 New Features Cookbook" that the JavaDocs are Section 508 compliant starting Java 7. (Section 508 is an accessibility standard.) I think this is really cool so wanted to mention it in this thread anyway.
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mine is autoclosing resources.


+1 here as well.

But I also think the feature of not repeating the declaration for Generics on both the sides of the declaration reduces the verbosity to some extent. And even Autoclosing would help in reducing the amount of code written.

Then there's a new Concurrency related feature (Fork-Join) and I think even that might be useful, but I dont know how ;)
 
Saloon Keeper
Posts: 15490
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Definitely try-with-resources, and generic type inference.

try-with-resources makes I/O code *so* much nicer to read. And I just feel a little bit happy every time I don't have to type the generic type argument.

Catching disjoint exceptions is nice too, as well as grouping numbers with underscores, but I don't use these features that often.

Java 7 is just a really nice language ^^;
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about being able to write numbers in binary? A feature which was available in languages like Eiffel back in the 1980s.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
+1 Try with resources
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess the try with resources feature gets a unanimous vote.
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
switch(String) is quite useful too

Pat.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So is catching multiple exceptions (catch (IOException | SQLException e). I still vote for try-with-resources.
 
author
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My personal favorite (and favorite recipe to write for our book) is the ability to manage the shape of a window in GUI applications, though I will admit this was more of a fun feature than something I have found particularly useful! From a more practical standpoint, I appreciate the simplicity of the Files class and Path interface for file I/O. Working with files and directories is greatly simplified in Java 7.
 
author
Posts: 84
5
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like the new concurrent processing features added to Java 7. There are not extensive, but they did allow me to write about zombies.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My personal top-3:
1. try-with-resources
2. (generic) type inference
3. string in switch
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've written systems multiple times where there had to be some process that checks regularly if a file is placed in a directory, which should then be picked up to be processed. You could do that by having a scheduled task that every X seconds or so lists the files in the directory to see if anything has appeared.

Java 7 has a new feature where you can ask to be notified when something changes in a directory. See Watching a Directory for Changes. Instead of polling, it will use the native functionality of the operating system for file system change notifications, which is most likely much more efficient than polling.

So, that's one of the new features that seems really useful to me.
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mine favorites are (from high to low priority)

1. try-with-resources (autoclose feature) - it takes boilerplate code of maintaining Streams/Connection out of scope for us
2. Diamond operator - makes code looks more better now
3. String in switch - aren't we missing this feature in Java since long ?

~ abhay

 
Bartender
Posts: 2661
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper de Jong wrote:...Java 7 has a new feature where you can ask to be notified when something changes in a directory.



That one!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic