導航:首頁 > 編程語言 > javastring編程題

javastring編程題

發布時間:2024-05-06 23:01:23

『壹』 java關於String編程

importjava.io.File;
importjava.io.FileWriter;
importjava.io.IOException;
importjava.util.ArrayList;
importjava.util.List;

publicclass${

privatestaticList<String>data=newArrayList<String>();

publicstaticvoidmain(String[]args){

try{
Stringstr="atihhhfughwedckgg";

//(1)用代碼實現統計有多少種字母,以及每個字母的個數,
test1(str);
System.out.println(data);

//(2)將查詢的數據存放到D盤根目錄下的Test文本文件下。
test2();
}catch(Exceptione){
e.printStackTrace();
}
}

privatestaticvoidtest1(Stringstr){

intlen=0;
Stringfst="";
while(str.length()>0){
len=str.length();
fst=str.substring(0,1);
str=str.replaceAll(fst,"");
data.add(fst+":"+(len-str.length()));
}
}

privatestaticvoidtest2()throwsIOException{

FileWriterfw=newFileWriter(newFile("d:/a.txt"));
for(Stringstr:data){
fw.write(str+" ");
}
fw.flush();
fw.close();
}
}

閱讀全文

與javastring編程題相關的資料

熱點內容
無錫人怎麼在APP里 瀏覽:810
安卓系統怎麼讓應用不保存緩存 瀏覽:482
高性能web站點pdf 瀏覽:980
scratch飛機大戰編程全程教學 瀏覽:2
java網路編程詳解 瀏覽:694
oppo手機如果應用加密了如何解開 瀏覽:898
q退出命令 瀏覽:758
java變數單例 瀏覽:482
javametainf 瀏覽:967
sys編譯軟體 瀏覽:640
學數控編程准備 瀏覽:156
可愛的程序員西米沒了 瀏覽:295
葉羅麗冰公主解壓本 瀏覽:981
車用空調壓縮機品牌 瀏覽:830
在回收站中可以恢復幾個文件夾 瀏覽:916
phpget轉義 瀏覽:322
我的世界寶可夢伺服器叫什麼名字 瀏覽:748
新聞編譯難嗎 瀏覽:582
ia架構伺服器是什麼意思 瀏覽:220
linux查看區域網 瀏覽:77