• 字符串大小写转换 更改字符串 去掉前后空格


    public class Homework {

        public static void main(String[] args) throws ParseException {
        
          
                lower();    全部调用


                upper();


                repalce();


                repalce1();


                trim();

          public static void  trim(){

    //  String trim(): 去掉字符串两端空格


                    String s="   hello    ";  //定义字符串两端加空格


                    System.out.println(s);  //打印一次


                    String s1=s.trim();  //去掉两端空格


                    System.out.println(s1);  //打印取掉以后的值
        }

    //    String repalce(String old, String newstr): 将字符串中的老字符串,替换为新字符串


                public static void repalce1(){


                   String s="old";  //定义字符串


                    String s1=s.replace("old","newstr");    //把old 替换成 newStr


                    System.out.println(s1);    //打印
        }

    //    String repalce(char oldChar, char newChar): 将字符串中的老字符,替换为新字符


              private static void repalce() {

      
                String s="oldChar";    //定义字符串
            
                  String s1=s.replace("old","new" );  //把old转化成new后面不变


                  System.out.println(s1);
        }



              private static void upper() {

    //    String toUpperCase(): 字符串转成大写


              String s="hello";  // 定义字符串


              String s1=s.toUpperCase();  //把字符串转换成大写


              System.out.println(s1);  //打印
        }


          private static void lower() {
       //      String toLowerCase(): 字符串转成小写


                String S="HELLO";  //定义大写字符串


                String s1=S.toLowerCase();    //把字符串转化成小写


                System.out.println(s1);      //打印
            
        }

      
      
        }

  • 相关阅读:
    IEEEXtreme 10.0
    IEEEXtreme 10.0
    IEEEXtreme 10.0
    IEEEXtreme 10.0
    IEEEXtreme 10.0
    IEEEXtreme 10.0
    Python/Anaconda多版本共存的解决方案
    玩转树莓派
    通过远程桌面连接树莓派
    树莓派的初次启动设置
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10561764.html
Copyright © 2020-2023  润新知