SORU
17 EKİM 2008, Cuma


Java 7'deki yeni özellikler

Yeni özellikler java 7'de uygulamaya ne olacak? Ve şimdi ne yapıyorlar?

CEVAP
10 Temmuz 2011, Pazar


Yapışkan notlar 7 Sürüm Notları 7 Features and Enhancements Java SE

Bu Java 7 yeni özellikler the OpenJDK 7 features page Özet

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]

Java 1.7 yeni özellikler için kod örnekleri

Deneyin-ile-kaynaklar deyim

bu:

BufferedReader br = new BufferedReader(new FileReader(path));
try {
   return br.readLine();
} finally {
   br.close();
}

olur:

try (BufferedReader br = new BufferedReader(new FileReader(path)) {
   return br.readLine();
}

Kapatmak için birden fazla kaynak bildirebilirsiniz:

try (
   InputStream in = new FileInputStream(src);
   OutputStream out = new FileOutputStream(dest))
{
 // code
}

Sayısal rakamları altını çizmektedir

int one_million = 1_000_000;

Anahtar dizeleri

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

İkili rakamları

int binary = 0b1001_1001;

Geliştirilmiş Tür Genel Örnek Oluşturma için Çıkarım

Map<String, List<String>> anagrams = new HashMap<String, List<String>>();

hale:

Map<String, List<String>> anagrams = new HashMap<>();

Birden çok özel durumu yakalamak

bu:

} catch (FirstException ex) {
     logger.error(ex);
     throw ex;
} catch (SecondException ex) {
     logger.error(ex);
     throw ex;
}

hale:

} catch (FirstException | SecondException ex) {
     logger.error(ex);
    throw ex;
}

SafeVarargs

bu:

@SuppressWarnings({"unchecked", "varargs"})
public static void printAll(List<String>... lists){
    for(List<String> list : lists){
        System.out.println(list);
    }
}

olur:

@SafeVarargs
public static void printAll(List<String>... lists){
    for(List<String> list : lists){
        System.out.println(list);
    }
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Amir Parmar

    Amir Parmar

    25 Kasım 2010
  • Julia Graf

    Julia Graf

    6 Mayıs 2006
  • Kindness

    Kindness

    23 Ocak 2006

İLGİLİ SORU / CEVAPLAR