UpperCase()方法将所有字符转换为大写字母。此方法有两个变体。第一个变体使用给定Locale的规则将此String中的所有字符转换为大写。这等效于调用toUpperCase(Locale.getDefault())。
示例
现在让我们看一个例子-import java.io.*;
public class Demo {
public static void main(String args[]) {
String Str = new String("This is it!");
System.out.print("Return Value :" );
System.out.println(Str.toUpperCase() );
}
}
输出结果Return Value :THIS IS IT!
示例
我们来看另一个实现toUpperCase()方法的示例-import java.io.*;
import java.util.Locale;
public class Demo {
public static void main(String args[]) {
String str = new String("This is it!");
System.out.print("Return Value :" );
System.out.println(str.toUpperCase() );
Locale ENGLISH = Locale.forLanguageTag("en");
String res = str.toUpperCase(ENGLISH);
System.out.println(res);
}
}
输出结果Return Value :THIS IS IT!
THIS IS IT!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/64220.html