Example:
String str = "AbC";
Convert all letters in the string to lowercase:
System.out.println(str.toLowerCase());
(Recommended video tutorial:java video)
Other methods:
import java.util.Scanner; public class Exercies3 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("输入大写字母:"); char ch = scan.next().charAt(0); while (ch <'A'|| ch > 'Z') { System.out.print("输入错误,请重新输入:"); ch =scan.next().charAt(0); } ch = (char) (ch + 32);//根据ASCII码,大写字母变为小写字母只需要+32即可 System.out.print("小写字母:" + ch); } }
Recommended tutorial:java entry program
The above is the detailed content of Java implements converting uppercase letters to lowercase letters. For more information, please follow other related articles on the PHP Chinese website!