3-数组与字符串终稿.ppt

NCEPU String类 - 2.String类的常用方法 String substring (int beginIndex ) 返回从beginIndex开始的子串 System.out.println ( s1.substring ( 2 ) ); 例如: String s1 = Hello; llo String substring (int beginIndex, int endIndex) 返回从beginIndex开始到endIndex之前的子串 System.out.println ( s1.substring(2, 4) ); ll NCEPU String类 - 2.String类的常用方法 String replace ( char oldChar, char newChar ) 将字符串中所有的oldChar转换为newChar System.out.println ( s1.replace ( l, t)); 例如: String s1 = Hello; Hetto int indexOf(String str) 返回str在字符串中第一次出现的位置 System.out.println ( s1.indexOf ( ell) ); 1 NCEPU String类 - 2.String类的常用方法 St

文档评论(0)

1亿VIP精品文档

相关文档