Java1.7和1.8新特性

2016-12-29  本文已影响246人  MC_Honva
1.7新特性
HashMap<String, String> parmas = new HashMap<>();
private static void customBufferStreamCopy(File source, File target) {
    try (InputStream fis = new FileInputStream(source);
        OutputStream fos = new FileOutputStream(target)){
  
        byte[] buf = new byte[8192];
  
        int i;
        while ((i = fis.read(buf)) != -1) {
            fos.write(buf, 0, i);
        }
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}
   public static void testThrows() throws IOException, SQLException { 
      try { 
           testThrows(); 
       } catch (IOException | SQLException ex) { 
           throw ex; 
       } 
   }
Java1.8新特性
public interface Demo {
    default public int add(int a,int b){
        return a+b;
    }
}

还有很多其他新特性,有时间再去看吧。哈哈哈

上一篇 下一篇

猜你喜欢

热点阅读