Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Java SE 7 <a href="http://www.oracle.com/technetwork/java/javase/jdk7-relnotes-418459.html" rel="noreferrer">Features and Enhancements</a> from JDK 7 Release Notes</h2> <p>This is the Java 7 new features summary from the <a href="http://openjdk.java.net/projects/jdk7/features/" rel="noreferrer">OpenJDK 7 features page</a>:</p> <blockquote> <pre> vm JSR 292: Support for dynamically-typed languages (InvokeDynamic) Strict class-file checking lang JSR 334: Small language enhancements (Project Coin) core Upgrade class-loader architecture Method to close a URLClassLoader Concurrency and collections updates (jsr166y) i18n Unicode 6.0 Locale enhancement Separate user locale and user-interface locale ionet JSR 203: More new I/O APIs for the Java platform (NIO.2) NIO.2 filesystem provider for zip/jar archives SCTP (Stream Control Transmission Protocol) SDP (Sockets Direct Protocol) Use the Windows Vista IPv6 stack TLS 1.2 sec Elliptic-curve cryptography (ECC) jdbc JDBC 4.1 client XRender pipeline for Java 2D Create new platform APIs for 6u10 graphics features Nimbus look-and-feel for Swing Swing JLayer component Gervill sound synthesizer [NEW] web Update the XML stack mgmt Enhanced MBeans [UPDATED] </pre> </blockquote> <h2>Code examples for new features in Java 1.7</h2> <h3>Try-with-resources statement</h3> <p>this:</p> <pre><code>BufferedReader br = new BufferedReader(new FileReader(path)); try { return br.readLine(); } finally { br.close(); } </code></pre> <p>becomes:</p> <pre><code>try (BufferedReader br = new BufferedReader(new FileReader(path)) { return br.readLine(); } </code></pre> <p>You can declare more than one resource to close:</p> <pre><code>try ( InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dest)) { // code } </code></pre> <h3>Underscores in numeric literals</h3> <pre><code>int one_million = 1_000_000; </code></pre> <h3>Strings in switch</h3> <pre><code>String s = ... switch(s) { case "quux": processQuux(s); // fall-through case "foo": case "bar": processFooOrBar(s); break; case "baz": processBaz(s); // fall-through default: processDefault(s); break; } </code></pre> <h3>Binary literals</h3> <pre><code>int binary = 0b1001_1001; </code></pre> <h3>Improved Type Inference for Generic Instance Creation</h3> <pre><code>Map&lt;String, List&lt;String&gt;&gt; anagrams = new HashMap&lt;String, List&lt;String&gt;&gt;(); </code></pre> <p>becomes:</p> <pre><code>Map&lt;String, List&lt;String&gt;&gt; anagrams = new HashMap&lt;&gt;(); </code></pre> <h3>Multiple exception catching</h3> <p>this:</p> <pre><code>} catch (FirstException ex) { logger.error(ex); throw ex; } catch (SecondException ex) { logger.error(ex); throw ex; } </code></pre> <p>becomes:</p> <pre><code>} catch (FirstException | SecondException ex) { logger.error(ex); throw ex; } </code></pre> <h3>SafeVarargs</h3> <p>this:</p> <pre><code>@SuppressWarnings({"unchecked", "varargs"}) public static void printAll(List&lt;String&gt;... lists){ for(List&lt;String&gt; list : lists){ System.out.println(list); } } </code></pre> <p>becomes:</p> <pre><code>@SafeVarargs public static void printAll(List&lt;String&gt;... lists){ for(List&lt;String&gt; list : lists){ System.out.println(list); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload