定义
toLowerCase() 方法用于把字符串转换为小写。
返回值
一个新的字符串,其中大写字母全换成小写。
package 做题;
import java.util.Scanner;
import javax.naming.StringRefAddr;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
String b = sc.nextLine();
// toLowerCase用法
a = a.toLowerCase();
b = b.toLowerCase();
int res = a.compareTo(b);
if(res == 0) System.out.println("=");
else if(res < 0) System.out.println("<");
else System.out.println(">");
}
}
该博客介绍了Java中的toLowerCase()方法,用于将字符串转换为小写,并展示了如何在字符串比较中使用此方法。通过示例代码解释了如何比较两个小写的字符串,输出它们的比较结果。
932

被折叠的 条评论
为什么被折叠?



