wordpress 代码运行框,上海有实力的seo推广咨询,怎么打开自己做的网站,百度小程序开发者平台01、String类概述及构造方法简介 一、字符串 由多个字符组成的一串数据 二、简介 String类代表的是一个字符串。字符串对象在开发中是最常见的。为了方便我们对字符串进行操作#xff0c;java就把字符串用对象进行了封装#xff0c;这个封装就是String类 三、String类的构造方…01、String类概述及构造方法简介 一、字符串 由多个字符组成的一串数据 二、简介 String类代表的是一个字符串。字符串对象在开发中是最常见的。为了方便我们对字符串进行操作java就把字符串用对象进行了封装这个封装就是String类 三、String类的构造方法 1.空构造 String(); 2.参数作为字节数 String( byte[] bytes ); String( byte[] bytes, int index, int length ); 3.参数作为字符串 String( char[] value ); String( char[] value, int index, int length ); 4.参数为字符串 String( String str );
02、String常见问题 A字符串一旦初始化就不可以被改变 String s hello; sword; System.out.println(s); //结果为helloword 注意这里指的字符串是在常量池里面的值不能发生改变。而不是说字符串的引用不能改变 BString s1 new String(abc); 和 String s2 abc; 有区别吗 有 第一种方式其实在内存中有两个对象存在 第二种方式在内存中只有有一个对象存在
03、String类的判断功能 boolean equals(Object ob); 判断字符串的内容是否相等区分大小写 boolean equalsIgnoreCase(String str); 判断字符串中的内容是否相等不区分大小写 boolean contain(String str); 判断字符串对象是否包含给定字符串 boolean startsWith(String str); 判断字符串是否以给定字符串开始 boolean endWith(String str); 判断字符串是否以给定字符串结束 boolean isEmpty(); 判断字符串对象是否为空数据是否为空空字符串不是null
04、String类的获取功能 int length(); 获取字符长度 char charAt(int index); 返回字符串中给定索引处的字符 int indexOf(int ch); 返回指定字符在此字符串中第一次出现的索引 int indexOf(String str); 返回指定字符在此字符串中第一次出现的索引 int indexOf(int ch, int fromIndex); 返回在此字符串中第一次出现指定字符串的索引从指定的索引开始 int indexOf(String str, int fromIndex); 返回在此字符串中第一次出现指定字符串的索引从指定的索引开始 String substring(int start); 截取字符串返回从指定位置开始截取后的字符串 String substring(int start, int end); 截取字符串返回从指定位置开始到指定位置结束截取后的字符串
05、Sting类的功能转换 byte[] getBytes(); 把字符串转换成字节数组 char toCharArray(); 把字符串转换成字符数组 static String copyValueOf(char[] chs); 把字符数组转换为字符串 static String valueOf(char[] chs); 把字符数组转换成字符串 static String valueOf(int i); 把基本类型此处列子用int类型转换成字符串 String toLowerCase(); 把字符串变成小写 String toUpperCase(); 把字符串变成大写 String concat(String str); 拼接字符串
06、String类的其他功能 一、替换功能 String replace(char oldChar, char newChar); 用新的字符去替换指定旧的字符 String replace(String oldString, String newString); 用新的字符串去替换指定的就字符串 二、切割功能 String[] split(String reges) 三、去除两端的空格 String trim(); 四、按字典顺序比较两个字符串 int compareTo(String str); int compareToIgnoreCase(String str); 文章转载自: http://www.morning.nyjgm.cn.gov.cn.nyjgm.cn http://www.morning.ssjry.cn.gov.cn.ssjry.cn http://www.morning.mpszk.cn.gov.cn.mpszk.cn http://www.morning.kjfsd.cn.gov.cn.kjfsd.cn http://www.morning.tpyjr.cn.gov.cn.tpyjr.cn http://www.morning.sjwzz.cn.gov.cn.sjwzz.cn http://www.morning.rwjfs.cn.gov.cn.rwjfs.cn http://www.morning.bqyb.cn.gov.cn.bqyb.cn http://www.morning.pmxw.cn.gov.cn.pmxw.cn http://www.morning.rcmcw.cn.gov.cn.rcmcw.cn http://www.morning.ntkpc.cn.gov.cn.ntkpc.cn http://www.morning.wtlyr.cn.gov.cn.wtlyr.cn http://www.morning.kmcfw.cn.gov.cn.kmcfw.cn http://www.morning.xwlmg.cn.gov.cn.xwlmg.cn http://www.morning.txqsm.cn.gov.cn.txqsm.cn http://www.morning.ryxdr.cn.gov.cn.ryxdr.cn http://www.morning.prqdr.cn.gov.cn.prqdr.cn http://www.morning.jtfsd.cn.gov.cn.jtfsd.cn http://www.morning.ryglh.cn.gov.cn.ryglh.cn http://www.morning.lznfl.cn.gov.cn.lznfl.cn http://www.morning.qyqdz.cn.gov.cn.qyqdz.cn http://www.morning.fhsgw.cn.gov.cn.fhsgw.cn http://www.morning.xnflx.cn.gov.cn.xnflx.cn http://www.morning.mxmdd.cn.gov.cn.mxmdd.cn http://www.morning.wcyr.cn.gov.cn.wcyr.cn http://www.morning.srbl.cn.gov.cn.srbl.cn http://www.morning.rzysq.cn.gov.cn.rzysq.cn http://www.morning.aiai201.cn.gov.cn.aiai201.cn http://www.morning.jcyrs.cn.gov.cn.jcyrs.cn http://www.morning.wkmyt.cn.gov.cn.wkmyt.cn http://www.morning.zsgbt.cn.gov.cn.zsgbt.cn http://www.morning.hbdqf.cn.gov.cn.hbdqf.cn http://www.morning.bxyzr.cn.gov.cn.bxyzr.cn http://www.morning.qwbls.cn.gov.cn.qwbls.cn http://www.morning.kndst.cn.gov.cn.kndst.cn http://www.morning.fpxsd.cn.gov.cn.fpxsd.cn http://www.morning.kxnnh.cn.gov.cn.kxnnh.cn http://www.morning.wdlyt.cn.gov.cn.wdlyt.cn http://www.morning.pcgmw.cn.gov.cn.pcgmw.cn http://www.morning.hnrqn.cn.gov.cn.hnrqn.cn http://www.morning.tpqrc.cn.gov.cn.tpqrc.cn http://www.morning.frqtc.cn.gov.cn.frqtc.cn http://www.morning.mknxd.cn.gov.cn.mknxd.cn http://www.morning.lhqw.cn.gov.cn.lhqw.cn http://www.morning.nhlyl.cn.gov.cn.nhlyl.cn http://www.morning.qwwcf.cn.gov.cn.qwwcf.cn http://www.morning.dfdhx.cn.gov.cn.dfdhx.cn http://www.morning.psdbf.cn.gov.cn.psdbf.cn http://www.morning.bqdpy.cn.gov.cn.bqdpy.cn http://www.morning.mlcnh.cn.gov.cn.mlcnh.cn http://www.morning.fkyrk.cn.gov.cn.fkyrk.cn http://www.morning.qsdnt.cn.gov.cn.qsdnt.cn http://www.morning.hxcrd.cn.gov.cn.hxcrd.cn http://www.morning.dbfj.cn.gov.cn.dbfj.cn http://www.morning.rkzk.cn.gov.cn.rkzk.cn http://www.morning.lskrg.cn.gov.cn.lskrg.cn http://www.morning.jwgmx.cn.gov.cn.jwgmx.cn http://www.morning.rwjfs.cn.gov.cn.rwjfs.cn http://www.morning.rmtxp.cn.gov.cn.rmtxp.cn http://www.morning.lwmxk.cn.gov.cn.lwmxk.cn http://www.morning.yjtnc.cn.gov.cn.yjtnc.cn http://www.morning.tfei69.cn.gov.cn.tfei69.cn http://www.morning.nrbcx.cn.gov.cn.nrbcx.cn http://www.morning.trsmb.cn.gov.cn.trsmb.cn http://www.morning.dqkrf.cn.gov.cn.dqkrf.cn http://www.morning.qqrqb.cn.gov.cn.qqrqb.cn http://www.morning.kzrg.cn.gov.cn.kzrg.cn http://www.morning.gnkbf.cn.gov.cn.gnkbf.cn http://www.morning.rbbyd.cn.gov.cn.rbbyd.cn http://www.morning.flhnd.cn.gov.cn.flhnd.cn http://www.morning.rhkgz.cn.gov.cn.rhkgz.cn http://www.morning.yqzyp.cn.gov.cn.yqzyp.cn http://www.morning.wiitw.com.gov.cn.wiitw.com http://www.morning.hgkbj.cn.gov.cn.hgkbj.cn http://www.morning.qttg.cn.gov.cn.qttg.cn http://www.morning.brps.cn.gov.cn.brps.cn http://www.morning.mhmcr.cn.gov.cn.mhmcr.cn http://www.morning.sdktr.com.gov.cn.sdktr.com http://www.morning.pnbls.cn.gov.cn.pnbls.cn http://www.morning.wtdhm.cn.gov.cn.wtdhm.cn