right2_5_3.htm
来自「清华JAVA教程。不用多说了吧」· HTM 代码 · 共 64 行
HTM
64 行
<html><head><title>JAVA编程语言</title><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><link rel="stylesheet" href="../../../css/text.css" type="text/css"></head><body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" ><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td valign="top"> <table width="95%" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF"> <tr> <td valign="top"> <p> <span class="pt9-black"> </span><span class="zhongdian"><a name="01"></a>1.String类提供的方法:<a name="01"></a></span><span class="pt9-black"><br> <br> concat( )<br> replace( )<br> substring( )<br> toLowerCase( )<br> toUpperCase( )<br> <font color="#000000"><br> ◇</font> public String contat(String str);<br> 用来将当前字符串对象与给定字符串str连接起来。<br> <font color="#000000"> ◇</font> public String replace(char oldChar,char newChar);<br> 用来把串中出现的所有特定字符替换成指定字符以生成新串。<br> <font color="#000000"> ◇</font> public String substring(int beginIndex);<br> public String substring(int beginIndex,int endIndex);<br> 用来得到字符串中指定范围内的子串。<br> <font color="#000000"> ◇</font> public String toLowerCase();<br> 把串中所有的字符变成小写。<br> <font color="#000000"> ◇</font> public String toUpperCase();<br> 把串中所有的字符变成大写。<br> <br> </span><span class="zhongdian">2.StringBuffer类提供的方法:<a name="02"></a></span><span class="pt9-black"><br> <br> append( )<br> insert( )<br> setCharAt( )<br> <br> 如果操作后的字符超出已分配的缓冲区,则系统会自动为它分配额外的空间。<br> <font color="#000000"> ◇</font> public synchronized StringBuffer append(String str);<br> 用来在已有字符串末尾添加一个字符串str。<br> <font color="#000000"> ◇</font> public synchronized StringBuffer insert(int offset, String str);<br> 用来在字符串的索引offset位置处插入字符串str。<br> <font color="#000000"> ◇</font> public synchronized void setCharAt(int index,char ch);<br> 用来设置指定索引index位置的字符值。 <br> <br> <b><font color="000099">注意:</font></b><font color="000099">String中对字符串的操作不是对源操作串对象本身进行的,而是对新生成的一个源操作串对象的拷贝进行的,其操作的结果不影响源串。<br> <br> 相反,StringBuffer中对字符串的连接操作是对源串本身进行的,操作之后源串的值发生了变化,变成连接后的串。</font></span></p> </td> </tr> </table> </td> </tr></table></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?