Skip to content

Instantly share code, notes, and snippets.

@kamekoopa
Last active August 29, 2015 14:10
Show Gist options
  • Save kamekoopa/bf941dd1bb449aff79ab to your computer and use it in GitHub Desktop.
Save kamekoopa/bf941dd1bb449aff79ab to your computer and use it in GitHub Desktop.
public class Stream {
public static void main(String[] args) {
Optional<String> result = Optional.empty();
for(String lang : Arrays.asList("C++", "Go", "Java", "Python", "Ruby")){
String _lang = lang.toUpperCase();
System.out.println("toUppercase(" + _lang + ")");
System.out.println("length(" + _lang + ")");
if(_lang.length() == 4){
result = Optional.of(_lang);
break;
}
}
}
}
/** http://itpro.nikkeibp.co.jp/atcl/column/14/224071/092600006/ のやつ */
public class Stream2 {
public static void main(String[] args){
for(int x : Arrays.asList(0,1,2,3,4,5)){
System.out.println("filter: " + x);
if(x%2==0){
System.out.println("map: " + x);
int _x = x/2;
System.out.println("forEach: " + _x);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment