<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Java Home

    Java技術修煉中...
    posts - 20, comments - 22, trackbacks - 0, articles - 0
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    數組對象getChars()方法的使用

    Posted on 2006-07-12 10:41 Yemoo'S Java Blog 閱讀(3099) 評論(2)  編輯  收藏 所屬分類: JAVA基礎知識
    java數組對象有一個很重要的方法getChars();其方法描述為:

    public void getChars(int srcBegin,int srcEnd,char dst[],int dstBegin);? 將當前字符串的部分字符復制到目標自負數組dst中,從srcBegin(包含在內)到srcEnd(不包含在內)之間的字符復制到目標字符數組中的字符從dstBegin位置開始存放.

    使用實例:
    String?ss="Visual?Basic";
    char?dst[]={'a','b','c','d'};

    ss.getChars(
    4,6,dst,2);
    System.out.println(dst);
    輸出結果為abal;

    注意數組參數只要寫入數組名即可,不要帶[],輸出可以直接用數組名輸出全部內容.

    評論

    # re: 數組對象getChars()方法的使用  回復  更多評論   

    2009-03-24 18:45 by anven
    你好,我剛剛在編寫代碼時候,出現了這樣的情況,在buf.getChars(0,buf.indexOf(new String ("<lesson")),tmp,0);時候,定義了一個tmp的char數組,這是循環使用這個數組,前后的數組成員的長度不同,因此在每一次的循環后,要求清空其中的內容,我使用一個
    for(int i=0,i<=100;i++)
    tmp[i]=0;
    這樣過后,卻出現不了預期的效果,卻只循環了一次就停止了!實在不知道錯在哪里!請教!
    import java.io.*;
    public class Filetest2
    {
    public static void main(String args[])
    {
    String str="";
    BufferedReader in =null;
    BufferedWriter out=null;
    char tmp[]=new char[50];
    int c=0;
    try
    {
    in = new BufferedReader(new FileReader("2.1.txt"));
    out= new BufferedWriter(new FileWriter("2.2.txt"));
    while((str=in.readLine())!=null)
    {
    String str1= str.toLowerCase().replaceAll(new String(" "),new String (""));
    StringBuffer buf= new StringBuffer(str1);
    System.out.println(buf.indexOf(new String ("<lesson")));
    if (buf.indexOf(new String ("<lesson"))!=-1)
    {
    buf.getChars(0,buf.indexOf(new String ("<lesson")),tmp,0);
    System.out.println(tmp);
    String Strtmp=new String(tmp);
    out.write(Strtmp);
    out.newLine();
    }

    // buf.getChars(0,buf.indexOf(new String ("<lesson"))-1,tmp,0);
    // System.out.println(tmp);
    //str1.getChars(str1.indexOf("*")+1,str1.indexOf("<"),tmp,0);
    //String Strtmp = new String(tmp);
    //System.out.println(str1);
    //out.write(str1);
    //out.newLine();
    }
    }
    catch(Exception e)
    {

    }
    finally
    {
    try{
    if(in!=null)
    if(out!=null)
    in.close();
    out.close();
    }
    catch(Exception e)
    {}

    }

    }

    }

    # re: 數組對象getChars()方法的使用  回復  更多評論   

    2011-05-05 20:50 by yx1989
    是因為你的數組長度和你getchars方法中獲得的字符串長度不一致,改一致了就可以了。

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲午夜国产精品无卡| 亚洲综合视频在线| 亚洲youwu永久无码精品| 97人妻无码一区二区精品免费| 亚洲高清在线视频| 午夜无码A级毛片免费视频| 亚洲av无码无在线观看红杏| 无码人妻一区二区三区免费n鬼沢 无码人妻一区二区三区免费看 | 亚洲国产成人久久精品大牛影视| 欧美a级在线现免费观看| 亚洲色最新高清av网站| 国产精品免费一级在线观看| 美女被爆羞羞网站在免费观看 | 2020因为爱你带字幕免费观看全集 | 亚洲成av人片在线观看天堂无码| 无人视频免费观看免费视频| 亚洲男人天堂2020| 免费无码黄网站在线看| 97se亚洲综合在线| 日韩一区二区a片免费观看 | 亚洲av永久无码精品秋霞电影秋 | 在线不卡免费视频| 一区二区三区在线免费| 久久亚洲一区二区| 国产精品永久免费10000| 337p日本欧洲亚洲大胆人人| 亚洲中文字幕丝袜制服一区| 三年片在线观看免费观看大全一 | 97se亚洲国产综合自在线| 国产乱子影视频上线免费观看| 一道本在线免费视频| 日木av无码专区亚洲av毛片| 最新猫咪www免费人成| 无码人妻一区二区三区免费视频 | 2022年亚洲午夜一区二区福利| 免费毛片在线看片免费丝瓜视频| 特级毛片爽www免费版| 亚洲精品中文字幕乱码影院| 国产一级淫片a视频免费观看| 久久免费精品视频| 亚洲AV日韩AV永久无码色欲|