看板 [ java ]
討論串[問題] 字串計數
共 8 篇文章
首頁
上一頁
1
2
下一頁
尾頁

推噓7(7推 0噓 1→)留言8則,0人參與, 最新作者smith80512 (Henry)時間9年前 (2014/10/10 16:08), 編輯資訊
4
0
1
內容預覽:
想請問版上前輩們. 文章內容已經分割成字串陣列. 如何計數該陣列重複的字串?. 並指顯示最多出現和次多出現的字串. 以及利用ArrayList回傳?. --. 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.235.218.46. 文章網址: http://www.ptt.cc/bb

推噓1(1推 0噓 1→)留言2則,0人參與, 最新作者cyclone350 (老子我最神)時間9年前 (2014/10/10 17:12), 編輯資訊
0
0
5
內容預覽:
依照推文說可用 map. key 使用字串值,value 使用number計數. 回傳list用 map 的 Entry 當泛型類別. 排序用 Collections 的 sort 實作. * 什麼是 Map: http://ppt.cc/WlxT. * 什麼是 Entry: http://ppt.
(還有64個字)

推噓1(1推 0噓 8→)留言9則,0人參與, 最新作者pelicanper (派立肯)時間9年前 (2014/10/10 18:32), 9年前編輯資訊
1
0
1
內容預覽:
1. 使用TreeMap, key: 字串 value:顯示次數. 2. 在Constructor裡面寫Comparator,並Override compare method. 把你要的logic寫入. 3. for each所有String array,插入TreeMap,. if 已經插入 va
(還有259個字)

推噓1(1推 0噓 5→)留言6則,0人參與, 最新作者cyclone350 (老子我最神)時間9年前 (2014/10/10 22:10), 9年前編輯資訊
0
0
3
內容預覽:
public List<Entry> wordCount(String[] allWords) {. Map<String, Integer> wordCountMap = wordCountToMap(allWords);. List<Entry> countList = new ArrayLis
(還有734個字)

推噓0(0推 0噓 6→)留言6則,0人參與, 最新作者smith80512 (Henry)時間9年前 (2014/10/10 22:55), 編輯資訊
1
0
1
內容預覽:
小弟愚鈍,使用TreeMap的方法,達成了計數字串的重複. 但試不出來怎麼對到ArrayList,我沒有說清楚. 回傳值一定要ArrayList<String>. public ArrayList<String> excute(String input) {. // TODO Auto-genera
(還有758個字)
首頁
上一頁
1
2
下一頁
尾頁