aspose file tools*
The moose likes Features new in Java 7 and the fly likes what is your favorite java 7 feature? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Features new in Java 7
Bookmark "what is your favorite java 7 feature?" Watch "what is your favorite java 7 feature?" New topic
Author

what is your favorite java 7 feature?

Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29233
    
136

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3054
    
  33

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 ;)


Mohamed Sanaulla | My Blog
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3370
    
    9
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 ^^;
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
What about being able to write numbers in binary? A feature which was available in languages like Eiffel back in the 1980s.
Alexis Lopez
Greenhorn

Joined: Dec 11, 2010
Posts: 7
+1 Try with resources
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

I guess the try with resources feature gets a unanimous vote.


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

switch(String) is quite useful too

Pat.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

So is catching multiple exceptions (catch (IOException | SQLException e). I still vote for try-with-resources.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jennifer Reese
author
Greenhorn

Joined: Mar 08, 2012
Posts: 8
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.
Richard Reese
author
Ranch Hand

Joined: Jul 13, 2011
Posts: 57

I like the new concurrent processing features added to Java 7. There are not extensive, but they did allow me to write about zombies.

Richard Reese
EJB 3.1 Cookbook
Java 7 New Features Cookbook
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4908
    
  10

My personal top-3:
1. try-with-resources
2. (generic) type inference
3. string in switch

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13869
    
  10

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1000
    
    1

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


Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2476
    
    7

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!


OCUP UML fundamental and ITIL foundation
youtube channel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is your favorite java 7 feature?
 
Similar Threads
508 Tools for Non-web java apps
section 508 compliant taglibrary
ajax and blind users
Extending JUnit
Doubt on updattable and insertable params