LoginSignup
0
0

More than 5 years have passed since last update.

Stream

Last updated at Posted at 2016-07-22

Stream記法のメモ

import java.util.*;

public class MyApp {

  public static void main(String[] args) {
    // Stream
    List<Integer> sales = new ArrayList<>(Arrays.asList(12, 30, 22, 4, 9));
    // for (Integer sale : sales) {
    //   System.out.println(sale);
    // }

    sales
      .stream()
      // 中間処理
      .filter(e -> e % 3 == 0) // ラムダ式 引数 -> 処理
      .map(e -> "(" + e + ")")
      // 終端処理
      .forEach(System.out::println);

  }

}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0