minixiong

toLowerCase()方法将String转换为小写。如果字符串中没有应该被转换的字符,则将原字符串返回,否则返回一个新的字符串。

语法:str.toLowerCase()

toUpperCase()方法将Srtring转换为大写。如果字符串中没有应该转换的字符,则将原字符串返回,否则返回一个新的字符串。

语法:str.toUpperCase()

说明:使用toLowerCase()方法和toUpperCase()方法进行大小写转换时,数字或非字符不受影响。

public class UpAndLower {//创建类
    public static void main(String args[]){//主方法
        String str = new String("abc DEF");//创建字符串str
        String newstr = str.toLowerCase();//使用toLowerCase()方法实现小写转换
        String newstr2 = str.toUpperCase();//使用toUpperCase()方法实现大写转换
        System.out.println(newstr);
        System.out.println(newstr2);
    }
}

  

分类:

技术点:

相关文章:

  • 2021-09-27
  • 2021-10-07
  • 2018-12-10
  • 2021-08-04
  • 2021-10-07
  • 2021-08-04
  • 2021-12-03
猜你喜欢
  • 2021-08-04
  • 2021-08-05
  • 2021-12-19
  • 2021-12-19
  • 2021-12-19
  • 2021-08-04
  • 2020-02-26
相关资源
相似解决方案