どうも、ちょげ(@chogetarou)です。
文字列(string)を全て小文字に変換する方法を紹介します。
方法

文字列(string)を全て小文字に変換するには、toLowerCase()を使います。
具体的には、「str.toLowerCase()
」のように、文字列からtoLowerCase()を呼び出します。
String result = text.toLowerCase();
toLowerCase()は、呼び出した文字列を全て小文字に変換した文字列を返します。
使用例
public class Main {
public static void main(String[] args) throws Exception {
String text = "HEELLO,WORLD";
String result = text.toLowerCase();
System.out.println(text);
System.out.println(result);
}
}
出力:
HEELLO,WORLD
heello,world
コメント