zoukankan      html  css  js  c++  java
  • 字符集及判断字符所在字符串位置

    //查找字符或字符串
    		int in = str2.indexOf("d");
    		
    		System.out.println("ab =" + in);
    		
    		int la = str2.lastIndexOf("d");//课后
    		
    		System.out.println("d =" + la);
    		
    		String newStr = str2.substring(5);
    		
    		newStr = str2.substring(5,6);
    		
    		System.out.println("substring() =" + newStr);
    		
    		str2 = " ab cdd s ";
    		
    		//去除前后空格
    		System.out.println("去空格 =" + str2.trim() + "后面");
    		
    		//查找替换
    		System.out.println("查找替换空格 =" + str2.replace(" ", "") + "后面");
    		
    		str2 = "abc,你好,abcd";
    		
    		System.out.println("查找替换 =" + str2.replace("abc", "李四") + "");
    		
    		System.out.println("查找替换 =" + str2.replaceFirst("abc", "张三") + "");
    		
    		str2 = "abcdef";
    		
    		//判断字符串开始和结束
    		System.out.println("判断起始1 =" + str2.startsWith("abc"));
    		
    		System.out.println("判断起始2 =" + (str2.indexOf("abc") == 0));
    		
    		System.out.println("判断结束  =" + str2.endsWith("ef") + "	");
    		
    

      

  • 相关阅读:
    upload1
    web2
    自动生成代码,简化开发
    rabbitmq简易安装
    jenkin安装
    mysql 数据插入为问号 ?
    git 基础复习
    git 使用,强制推远程仓库
    Spring 源码解析(持续集成,哈哈)
    ContainerBase.addChild: start: 错误
  • 原文地址:https://www.cnblogs.com/fangchongyan/p/5057173.html
Copyright © 2011-2022 走看看