Java 7 -

int million = 1_000_000; long creditCard = 1234_5678_9012_3456L; Binary Literals int mask = 0b1010_0101; // prefix 0b or 0B 2. New File I/O (NIO.2) – java.nio.file Replaced legacy File class.

// Before Java 7 BufferedReader br = null; try br = new BufferedReader(new FileReader("file.txt")); br.readLine(); catch (IOException e) e.printStackTrace(); finally { if (br != null) try br.close(); catch (IOException e) {} } // Java 7 try (BufferedReader br = new BufferedReader(new FileReader("file.txt"))) br.readLine(); catch (IOException e) e.printStackTrace(); java 7

Path path = Paths.get("/home/user/data.txt"); // Create/delete Files.createDirectories(path.getParent()); Files.deleteIfExists(path); // Copy Files.copy(Paths.get("source.txt"), Paths.get("dest.txt"), StandardCopyOption.REPLACE_EXISTING); // Read all lines (small files) List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8); // Walk a directory try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get("/home"))) for (Path entry : stream) System.out.println(entry.getFileName()); int million = 1_000_000

// Before: Map<String, List<String>> map = new HashMap<String, List<String>>(); Map<String, List<String>> map = new HashMap<>(); // Diamond Strings in switch String day = "MONDAY"; switch (day) case "MONDAY": System.out.println(1); break; case "TUESDAY": System.out.println(2); break; default: System.out.println(0); long creditCard = 1234_5678_9012_3456L

1. Language Changes (Project Coin) Try-with-Resources (AutoCloseable) Automatically closes resources implementing AutoCloseable .