无涯教程-Java - String toUpperCase()函数

130 阅读1分钟

将字符串转成大写字母,这等效于调用toUpperCase(Locale.getDefault())。

String toUpperCase() - 语法

public String toUpperCase()

String toUpperCase() - 返回值

  • 它返回字符串,并转换为大写。

String toUpperCase() - 示例

import java.io.*;
public class Test {

   public static void main(String args[]) {
      String Str=new String("Welcome to Learnfk.com");

      System.out.print("返回值 :" );
      System.out.println(Str.toUpperCase() );
   }
}

这将产生以下输出-

返回值 :WELCOME TO LEARNFK.COM

参考链接

www.learnfk.com/java/java-s…