java中怎样把字符串小写转化为大写
发布网友
发布时间:2022-04-24 14:27
我来回答
共2个回答
热心网友
时间:2022-04-24 15:56
String的toUpperCase()方法
Java String.toUpperCase(Locale locale)方法用法实例教程,将在此字符串中的所有字符为大写的规则给定的Locale
package com.yii;
import java.lang.*;
import java.util.*;
public class StringDemo {
public static void main(String[] args) {
String str1 = "This is TutorialsPoint";
// using the default system Locale
Locale defloc = Locale.getDefault();
// converts all lower case letters in to upper case letters
System.out.println("string value = " + str1.toUpperCase(defloc));
str1 = "www.baidu.com";
System.out.println("string value = " + str1.toUpperCase(defloc));
}
}
让我们来编译和运行上面的程序,这将产生以下结果:
string value = THIS IS TUTORIALSPOINT
string value = WWW.BAIDU.COM
热心网友
时间:2022-04-24 17:14
s = s.toUpperCase();