ラムダ式を使ってリスト配列からローマ字を大文字から小文字に変換するプログラムを作りました。
// 乃木坂新4期生メンバーをローマ字の大文字から小文字に変換する
// Create 2021/7/3
// Author 乃木坂好きのITエンジニア
//
//
//
//APIのimport
import java.util.ArrayList;
import java.util.Scanner;
class NewYonki {
public static void main(String[] args) {
ArrayList<String> name_list = new ArrayList<String>();
Scanner sc = new Scanner(System.in);
System.out.println("人数を5人ローマ字大文字で入力してください");
for(int i=0;i<5;i++) {
String line = sc.nextLine();
name_list.add(line);
}
//ラムダ関数でリスト配列の要素を全て小文字にする
name_list.replaceAll(s -> s.toLowerCase());
System.out.println(name_list);
sc.close();
}
}
ラムダ関数を使うとプログラム作成が楽ですね