Stream API とは? Stream APIは Java8 で導入された機能です。配列やCollectionなどの集合体を扱う為のもので、 値の集計やデータを使った処理などが出来る便利なAPIです。 Streamを用いる事で、拡張for文を簡略化することが出来ます。 Streamの使い方 各要素の数をカウントする(count) public class Sample { public static void main(String[] args) { List<String> JS = new ArrayList<>(Arrays.asList("Vue", "React", "Angular")); long count = JS.stream().count(); System.out.println(count); // 3 } } public class Sample {
![【Java】Stream API を使ってListを操作する方法 - Qiita](https://cdn-ak-scissors.b.st-hatena.com/image/square/44138693e9f594789ac218f3219c90d5612b7130/height=288;version=1;width=512/https%3A%2F%2Fqiita-user-contents.imgix.net%2Fhttps%253A%252F%252Fcdn.qiita.com%252Fassets%252Fpublic%252Fadvent-calendar-ogp-background-7940cd1c8db80a7ec40711d90f43539e.jpg%3Fixlib%3Drb-4.0.0%26w%3D1200%26mark64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZ3PTk3MiZoPTM3OCZ0eHQ9JUUzJTgwJTkwSmF2YSVFMyU4MCU5MVN0cmVhbSUyMEFQSSUyMCVFMyU4MiU5MiVFNCVCRCVCRiVFMyU4MSVBMyVFMyU4MSVBNkxpc3QlRTMlODIlOTIlRTYlOTMlOEQlRTQlQkQlOUMlRTMlODElOTklRTMlODIlOEIlRTYlOTYlQjklRTYlQjMlOTUmdHh0LWFsaWduPWxlZnQlMkN0b3AmdHh0LWNvbG9yPSUyMzNBM0MzQyZ0eHQtZm9udD1IaXJhZ2lubyUyMFNhbnMlMjBXNiZ0eHQtc2l6ZT01NiZzPTk3MzI4YzBiZTJmOWE4MmU0MzI0NjBlZDhkNGUyY2Y3%26mark-x%3D120%26mark-y%3D96%26blend64%3DaHR0cHM6Ly9xaWl0YS11c2VyLWNvbnRlbnRzLmltZ2l4Lm5ldC9-dGV4dD9peGxpYj1yYi00LjAuMCZoPTc2Jnc9OTcyJnR4dD0lNDB0X3QyMzgmdHh0LWNvbG9yPSUyMzNBM0MzQyZ0eHQtZm9udD1IaXJhZ2lubyUyMFNhbnMlMjBXNiZ0eHQtc2l6ZT0zNiZ0eHQtYWxpZ249bGVmdCUyQ3RvcCZzPTRkMTBiOGQyZDdkZGE3ODU5ZDUzZGQ3ODYxZTM2YWQx%26blend-x%3D120%26blend-y%3D445%26blend-mode%3Dnormal%26txt64%3DaW4g5qCq5byP5Lya56S-44OI44Op44K544OI%26txt-width%3D972%26txt-clip%3Dend%252Cellipsis%26txt-color%3D%25233A3C3C%26txt-font%3DHiragino%2520Sans%2520W6%26txt-size%3D36%26txt-x%3D134%26txt-y%3D546%26s%3D1f632d3ec9f0ce89ba23d0f07a532706)