Skip to content

Instantly share code, notes, and snippets.

@shui
Created August 31, 2017 08:27
Show Gist options
  • Save shui/5cb8bc8e043b57d664a69b6b69de2710 to your computer and use it in GitHub Desktop.
Save shui/5cb8bc8e043b57d664a69b6b69de2710 to your computer and use it in GitHub Desktop.
拥抱Java 8
        List<String> sList = new ArrayList<>(3);
        sList.add("a");
        sList.add("b");
        sList.add("c");
        // before 1.5
        for (int i = 0; i < 3; i++) {
            System.out.println(sList.get(i));
        }
        // 1.5
        for (String s :
                sList) {
            System.out.println(s);
        }
        // 1.8
        sList.forEach(System.out::println);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment