Skip to content

Instantly share code, notes, and snippets.

@kodaitakahashi
Created April 10, 2017 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kodaitakahashi/d2f83f31211e12efe746541777954b0c to your computer and use it in GitHub Desktop.
Save kodaitakahashi/d2f83f31211e12efe746541777954b0c to your computer and use it in GitHub Desktop.
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class Stream1 {
public static void main(String[] args) {
List<String> strings = Arrays.asList("b", "a", "d");
for (int i = 0; i < strings.size(); i++) {
strings.set(i, strings.get(i).toUpperCase());
}
System.out.println("-----------Stream なし--------------");
Collections.sort(strings);
for (String string : strings) {
System.out.println(string);
}
System.out.println("-----------Stream あり--------------");
strings.stream().sorted().forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment