Home >Java >javaTutorial >Java implements converting uppercase letters to lowercase letters

Java implements converting uppercase letters to lowercase letters

王林
王林Original
2020-05-09 10:26:5816107browse

Java implements converting uppercase letters to lowercase letters

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 <&#39;A&#39;|| ch > &#39;Z&#39;)
        {
            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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn