zoukankan      html  css  js  c++  java
  • 字符串大小写转换 更改字符串 去掉前后空格

    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);      //打印
            
        }

      
      
        }

  • 相关阅读:
    6.Docker中上传镜像到docker hub中
    altermanager使用报错
    Grafana官方和社区提供的dashboard
    什么是 云原生?
    prometheus被OOM杀死
    新版GRANAFA K8S插件 K8S NODE 图表不显示问题解决方法
    python2和python3的不同
    一次使用Python连接数据库生成二维码并安装为windows服务的工作任务
    Python连接oracle
    numpy.ndarray的赋值操作
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10561764.html
Copyright © 2011-2022 走看看