⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 right2_5_2.htm

📁 清华大学JAVA教程
💻 HTM
字号:
<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中提供了length(               )、charAt( )、indexOf( )、lastIndexOf( )、getChars( )、getBytes( )、toCharArray(               )等方法。<a name="01"></a></span><span class="pt9-black"><br>              <font color="#000000"><b><br>                </b>◇</font> public int length() 此方法返回字符串的字符个数<br>              <font color="#000000"><b>  </b>◇</font> public char charAt(int index)               此方法返回字符串中index位置上的字符,其中index 值的 范围是0~length-1<br>              <font color="#000000"><b>  </b>◇</font> public int indexOf(int ch)<br>                  public lastIndexOf(in ch)<br>                <br>                返回字符ch在字符串中出现的第一个和最后一个的位置<br>              <font color="#000000"><b>  </b>◇</font> public int indexOf(String               str)<br>                  public int lastIndexOf(String str)<br>                返回子串str中第一个字符在字符串中出现的第一个和最后一个的位置 <br>              <font color="#000000"><b>  </b>◇</font> public int indexOf(int ch,int               fromIndex)<br>                  public lastIndexOf(in ch ,int fromIndex)<br>                返回字符ch在字符串中位置fromIndex以后出现的第一个和最后一个的位置<br>              <font color="#000000"><b>  </b>◇</font> public int indexOf(String               str,int fromIndex)<br>                  public int lastIndexOf(String str,int fromIndex)<br>                返回子串str中的第一个字符在字符串中位置fromIndex后出现的第一个和最后一个的位置。<br>              <font color="#000000"><b>  </b>◇</font> public void getchars(int               srcbegin,int end ,char buf[],int dstbegin)<br>                 srcbegin 为要提取的第一个字符在源串中的位置, end为要提取的最后一个字符在源串中的位置,字符数组buf[]存放目的字符串,                  dstbegin 为提取的字符串在目的串中的起始位置。 <br>              <font color="#000000"><b>  </b>◇</font>public void getBytes(int               srcBegin, int srcEnd,byte[] dst, int dstBegin)<br>                参数及用法同上,只是串中的字符均用8位表示。<br>              <br>               </span><span class="zhongdian">2.类StringBuffer提供了 length( )、charAt(               )、getChars( )、capacity()等方法。<a name="02"></a></span><span class="pt9-black"><br>              <br>                方法capacity()用来得到字符串缓冲区的容量,它与方法length()所返回的值通常是不同的。<br>              </span> </p>            </td>        </tr>      </table>    </td>  </tr></table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -