java 字浮串提取方法匯集
更新時間:2008年10月01日 00:11:11 作者:
用方法toCharArray
public char[] toCharArray()
該方法把該字符串轉換成一個新的字符數組。
String str="abcdefg";
char a[];
a=str.toCharArray();
也可以用方法:
getChars
public void getChars(int srcBegin,
int srcEnd,
char dst[],
int dstBegin)
從該字符串中拷貝字符到目的字符數組中。
第一個要復制的字符在索引 srcBegin 處; 最后一個要復制的字符在索引 srcEnd-1 處(因此要復制的字符總數就是 srcEnd-srcBegin) 。要復制到 dst 子數組的字符開始于索引 dstBegin ,結束于索引:
dstbegin + (srcEnd-srcBegin) - 1
參數:
srcBegin - 要復制的字符串中第一個字符的索引。
srcEnd - 要復制的字符串中最后一個字符的索引。
dst - 目標數組。
dstBegin - 目標數組中的開始偏移量。
String str="abcdefg";
char a[];
str.getChars(0,str.length(),a,0);
寫的有點亂,但認真分析還是很有意思的
String str="abcdefg";
char a[];
a=str.toCharArray();
也可以用方法:
getChars
public void getChars(int srcBegin,
int srcEnd,
char dst[],
int dstBegin)
從該字符串中拷貝字符到目的字符數組中。
第一個要復制的字符在索引 srcBegin 處; 最后一個要復制的字符在索引 srcEnd-1 處(因此要復制的字符總數就是 srcEnd-srcBegin) 。要復制到 dst 子數組的字符開始于索引 dstBegin ,結束于索引:
dstbegin + (srcEnd-srcBegin) - 1
參數:
srcBegin - 要復制的字符串中第一個字符的索引。
srcEnd - 要復制的字符串中最后一個字符的索引。
dst - 目標數組。
dstBegin - 目標數組中的開始偏移量。
String str="abcdefg";
char a[];
str.getChars(0,str.length(),a,0);
寫的有點亂,但認真分析還是很有意思的
相關文章
Spring加載配置和讀取多個Properties文件的講解
今天小編就為大家分享一篇關于Spring加載配置和讀取多個Properties文件的講解,小編覺得內容挺不錯的,現在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03idea創(chuàng)建springboot項目,Application.java不能運行問題及解決
這篇文章主要介紹了idea創(chuàng)建springboot項目,Application.java不能運行問題及解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-11-11springboot使用filter獲取自定義請求頭的實現代碼
這篇文章主要介紹了springboot使用filter獲取自定義請求頭的實例代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-05-05