当前位置: 首页 > 文档资料 > 学习 Java 编程 >

String toUpperCase()

优质
小牛编辑
115浏览
2023-12-01

描述 (Description)

该方法有两种变体。 第一个变量使用给定Locale的规则将此String中的所有字符转换为大写。 这相当于调用toUpperCase(Locale.getDefault())。

第二个变体将locale作为在转换为大写时使用的参数。

语法 (Syntax)

以下是此方法的语法 -

public String toUpperCase()

参数 (Parameters)

这是参数的细节 -

  • NA

返回值 (Return Value)

  • 它返回String,转换为大写。

例子 (Example)

import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str = new String("Welcome to iowiki.com");
      System.out.print("Return Value :" );
      System.out.println(Str.toUpperCase() );
   }
}

这将产生以下结果 -

输出 (Output)

Return Value :WELCOME TO iowiki.com