java中怎样把字符串小写转化为大写

来源:百度知道 编辑:UC知道 时间:2024/05/09 05:33:30
如有个String s="wangxu";
该怎样把它转化为大写;

s = s.toUpperCase();

String的toUpperCase()方法

Java String.toUpperCase(Locale locale)方法用法实例教程,将在此字符串中的所有字符为大写的规则给定的Locale

package com.yiibai;

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.toUppe