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

      
      
        }

  • 相关阅读:
    转:CSS设置HTML元素的高度与宽度的各种情况总结
    Java、mysql、html、css、js 注释&大小写
    Dom4j与sax 简单对比
    转:Java properties | FileNotFoundException: properties (系统找不到指定的文件。)
    转:SAX解析的characters方法被多次调用
    转:HashMap实现原理分析(面试问题:两个hashcode相同 的对象怎么存入hashmap的)
    转:Scanner中nextLine()方法和next()方法的区别
    转:JDBC中关于PreparedStatement.setObject的一些细节说明
    转:Eclipse 各种小图标的含义
    转:Mysql float类型where 语句判断相等问题
  • 原文地址:https://www.cnblogs.com/hph1728390/p/10561764.html
Copyright © 2011-2022 走看看