Home> Java> javaTutorial> body text

Java implements converting uppercase letters to lowercase letters

王林
Release: 2020-05-09 10:26:58
Original
15992 people have browsed it

Java implements converting uppercase letters to lowercase letters

Example:

String str = "AbC";
Copy after login

Convert all letters in the string to lowercase:

System.out.println(str.toLowerCase());
Copy after login

(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); } }
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!