javaメモ
キー | バリュー |
---|---|
List リストの定義 | List<String> names = Arrays.asList("myname" |
List リストの定義(値の変更不可) | String names = List.of("myname" |
List 要素の取得 | names.get(0); |
List 要素の書き換え | names.set(1 |
List 要素の追加 | names.add("ather_name"); |
List 要素数の取得 | names.size(); |
Stream .filter() 中間処理(3文字より多いものを抽出) | collections_name.stream().filter(s -> s.length > 3).終端処理 |
Stream .limit(2) 中間処理(2件までに制限して抽出) | collections_name.stream().limit(2).終端処理 |
Stream .map() 中間処理(10倍した値に書き換え) | collections_name.stream().map(n -> n * 10).終端処理 |
Stream .map() 中間処理(大文字に変換) | collections_name.stream().map(s -> s.toUpperCase()).終端処理 |
Stream .sorted() 中間処理(並べ替え) | collections_name.stream().sorted().終端処理 |
Stream 生成 | Arrays.stream(collections_name); |
Stream 終端処理(文字の連結、区切り文字カンマ) | collections_name.stream().中間処理.collect(Collectors.joining(" |
Stream 終端処理(文字の連結) | collections_name.stream().中間処理.collect(Collectors.joining()); |
型変換 int(Integer)をStringへ | String.valueOf( int型 ) |
型変換 Longへ | Long.valueOf(String) |
型変換 Stringへ | 各データ型 . toString() |
型変換 StringをIntegerへ | Integer.valueOf(String) NumberFormatException発生しない |
配列 一括代入 | int[] numbers = new int[5]; numbers = new int[]{1, 2, 3, 4, 5}; |
Copyrights © 2019 - Imran Hossain, All Rights Reserved.