導航:首頁 > 編程語言 > 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編程題相關的資料

熱點內容
胸7椎體輕度壓縮 瀏覽:108
sk5伺服器什麼意思 瀏覽:554
什麼是廊坊交警app 瀏覽:294
衣櫃造價演算法 瀏覽:984
默認的web伺服器地址 瀏覽:694
單片機與發光二極體 瀏覽:320
pythonwebmodule 瀏覽:328
空調壓縮機不停了 瀏覽:115
python序列怎麼取 瀏覽:199
線上資料庫加密怎麼查詢 瀏覽:794
js中數據加密 瀏覽:470
穴pdf 瀏覽:548
阿里雲伺服器雲資料庫還需要嗎 瀏覽:146
在程序設計中常用的演算法有哪些 瀏覽:977
為什麼蘇州公積金app一直維護 瀏覽:805
有ip地址但是dhcp伺服器 瀏覽:446
三星手機加密中斷怎麼回事 瀏覽:538
訓練模型init源碼 瀏覽:840
程序編譯是誰的功能 瀏覽:505
qq收藏怎樣設置加密 瀏覽:291