1. 程式人生 > >一些瑣碎的java知識點

一些瑣碎的java知識點

 int length()                           返回當前字串的長度
 int indexOf(int ch)                     查詢ch字元在該字串中第一次出現的位置
 int indexOf(String str)                  查詢str子字串在該字串中第一次出現的位置
 int lastIndexOf(String str)               查詢str子字串在該字串中最後一次出現的位置
 int lastIndexOf(int ch)                  查詢ch字元在該字串中最後一次出現的位置
 String substring(int beginIndex)            獲取從beginIndex位置開始到結束的子字串
 String substring(int beginIndex,int endIndex)   獲取從beginIndex位置開始到endIndex的子字串
 String trim()                         返回去除了前後空格的字串
 boolean equals(Object obj)                該字串與指定物件比較,返回true或false
 String toLowerCase()                    將字串轉換為小寫
 String toUpperCase ()                   將字串轉換為大寫
 char charAt ()                        獲取字串中指定位置的字元
 String[] spilt spilt(String regex,int limit)  將字串分割為子字串,返回字串陣列
 byte [] getBytes()                     將該字串轉換為byte陣列