scala String對象的方法


String 方法
	
char charAt(int index)
返回指定位置的字符  從0開始
	
int compareTo(Object o)
比較字符串與對象
	
int compareTo(String anotherString)
按字典順序比較兩個字符串
	
int compareToIgnoreCase(String str)
按字典順序比較兩個字符串,不考慮大小寫
	
String concat(String str)
將指定字符串連接到此字符串的結尾
	
boolean contentEquals(StringBuffer sb)
將此字符串與指定的 StringBuffer 比較。
	
static String copyValueOf(char[] data)
返回指定數組中表示該字符序列的 String
	
static String copyValueOf(char[] data, int offset, int count)
返回指定數組中表示該字符序列的 String
	
boolean endsWith(String suffix)
測試此字符串是否以指定的后綴結束
	
boolean equals(Object anObject)
將此字符串與指定的對象比較
	
boolean equalsIgnoreCase(String anotherString)
將此 String 與另一個 String 比較,不考慮大小寫
	
byte getBytes()
使用平台的默認字符集將此 String 編碼為 byte 序列,並將結果存儲到一個新的 byte 數組中
	
byte[] getBytes(String charsetName
使用指定的字符集將此 String 編碼為 byte 序列,並將結果存儲到一個新的 byte 數組中
	
void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
將字符從此字符串復制到目標字符數組
	
int hashCode()
返回此字符串的哈希碼
16	
int indexOf(int ch)
返回指定字符在此字符串中第一次出現處的索引(輸入的是ascii碼值)
	
int indexOf(int ch, int fromIndex)
返返回在此字符串中第一次出現指定字符處的索引,從指定的索引開始搜索
	
int indexOf(String str)
返回指定子字符串在此字符串中第一次出現處的索引
	
int indexOf(String str, int fromIndex)
返回指定子字符串在此字符串中第一次出現處的索引,從指定的索引開始
	
String intern()
返回字符串對象的規范化表示形式
	
int lastIndexOf(int ch)
返回指定字符在此字符串中最后一次出現處的索引
	
int lastIndexOf(int ch, int fromIndex)
返回指定字符在此字符串中最后一次出現處的索引,從指定的索引處開始進行反向搜索
	
int lastIndexOf(String str)
返回指定子字符串在此字符串中最右邊出現處的索引
	
int lastIndexOf(String str, int fromIndex)
返回指定子字符串在此字符串中最后一次出現處的索引,從指定的索引開始反向搜索
	
int length()
返回此字符串的長度
	
boolean matches(String regex)
告知此字符串是否匹配給定的正則表達式
	
boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
測試兩個字符串區域是否相等
28	
boolean regionMatches(int toffset, String other, int ooffset, int len)
測試兩個字符串區域是否相等
	
String replace(char oldChar, char newChar)
返回一個新的字符串,它是通過用 newChar 替換此字符串中出現的所有 oldChar 得到的
	
String replaceAll(String regex, String replacement
使用給定的 replacement 替換此字符串所有匹配給定的正則表達式的子字符串
	
String replaceFirst(String regex, String replacement)
使用給定的 replacement 替換此字符串匹配給定的正則表達式的第一個子字符串
	
String[] split(String regex)
根據給定正則表達式的匹配拆分此字符串
	
String[] split(String regex, int limit)
根據匹配給定的正則表達式來拆分此字符串
	
boolean startsWith(String prefix)
測試此字符串是否以指定的前綴開始
	
boolean startsWith(String prefix, int toffset)
測試此字符串從指定索引開始的子字符串是否以指定前綴開始。
	
CharSequence subSequence(int beginIndex, int endIndex)
返回一個新的字符序列,它是此序列的一個子序列
	
String substring(int beginIndex)
返回一個新的字符串,它是此字符串的一個子字符串
	
String substring(int beginIndex, int endIndex)
返回一個新字符串,它是此字符串的一個子字符串
	
char[] toCharArray()
將此字符串轉換為一個新的字符數組
	
String toLowerCase()
使用默認語言環境的規則將此 String 中的所有字符都轉換為小寫
	
String toLowerCase(Locale locale)
使用給定 Locale 的規則將此 String 中的所有字符都轉換為小寫
	
String toString()
返回此對象本身(它已經是一個字符串!)
	
String toUpperCase()
使用默認語言環境的規則將此 String 中的所有字符都轉換為大寫
	
String toUpperCase(Locale locale)
使用給定 Locale 的規則將此 String 中的所有字符都轉換為大寫
	
String trim()
刪除指定字符串的首尾空白符
	
static String valueOf(primitive data type x)
返回指定類型參數的字符串表示形式

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM