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

      
      
        }

  • 相关阅读:
    负载均衡算法实现方式
    TCP三次握手和四次挥手
    深度解析Java内存原型
    缓存击穿、缓存穿透和缓存雪崩
    uni-app分包加载
    vuex的使用
    在web中打开exe程序并传参
    Vue 中引用高德地图
    .Net Core 从MySql数据库生成实体类 Entity Model
    vs2017 创建项目推送到Git上
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10561764.html
Copyright © 2011-2022 走看看