Re: [問題] 請問如何將code不要寫死,不需要重新編쐠…

看板java作者 (挺)時間16年前 (2009/10/23 02:05), 編輯推噓2(201)
留言3則, 2人參與, 最新討論串5/10 (看更多)
※ 引述《xlk (深深)》之銘言: : 標題: Re: [問題] 請問如何將code不要寫死,不需要重新編쐠… : : for (CalendarEventEntry entry : feeds.getEntries()) { : : // 日曆事件title : String title = entry.getTitle().getPlainText(); : : if (titles.contains(title)) {// 看看有沒有在List裡! : : // 計算event花費時間, 許多時間類別內部以long type表示時間絕對值 : : // 對照title在list裡的位置來紀錄event的次數與總時數 : int index = titles.indexOf(title); : // List<String> titles = new ArrayList<String>(); : : eventCount[index]++; : : // 印出event資訊 : System.out.print("事件: " + title); : } : 感謝你熱心解答 可是不知道為什麼你會想出這方法解決,把code變成活的呢? 利用NetBeans除錯專案(中斷點)查看 每個 區域變數 值 其中 int index = titles.indexOf(title); 我還是搞不懂indexOf意似 為什麼String會變成int 至於分類title寫出來了 String GoogleTitle = entry.getTitle().getPlainText(); if (ListTitles.contains(GoogleTitle)) {// 看看有沒有在List // 對照title在list裡的位置來紀錄event的次數與總時數 index = ListTitles.indexOf(GoogleTitle); eventCount[index]++; ii = ii + 1; // 印出event資訊 for (int j = -1; j < ListTitles.size(); j++) { if (index == j) { System.out.println("第 " + ii + " 次數 第 " + j + " 類 事件: " + GoogleTitle) }//if }//for }//if -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.137.254.170

10/23 08:07, , 1F
什麼「意似」我不知道,想知道就去問香蕉,ㄜ...問 API
10/23 08:07, 1F

10/23 08:10, , 2F
基於程度(比較值),本篇文章給予「作業文條款」警告
10/23 08:10, 2F

10/23 09:20, , 3F
個別指導請播付費專線 :P
10/23 09:20, 3F
文章代碼(AID): #1Au9xq0W (java)
討論串 (同標題文章)
以下文章回應了本文
完整討論串 (本文為第 5 之 10 篇):
文章代碼(AID): #1Au9xq0W (java)