将字符串转换为大写和小写的 Java 程序。


示例

实际演示

import java.lang.*;
public class StringDemo {
   public static void main(String[] args) {  
      // converts all upper case letters in to lower case letters
      String str1 = "SELF LEARNING CENTER";
      System.out.println("string value = " + str1.toLowerCase());

      str1 = "TUTORIALS POINT";    
      System.out.println("string value = " + str1.toLowerCase());

      // converts all lower case letters in to upper case letters
      String str2 = "This is TutorialsPoint";
      System.out.println("string value = " + str2.toUpperCase());

      str2 = "www.tutorialspoint.com";
      System.out.println("string value = " + str2.toUpperCase());      
   }  
} 

输出

string value = self learning center
string value = tutorials point
string value = THIS IS TUTORIALSPOINT
string value = WWW.TUTORIALSPOINT.COM

更新时间: 18-6-2020

939 次浏览

启动您的职场

完成课程以获得认证

开始
广告