作者nation6238 (挺)
看板java
標題Re: [問題] 請問如何將code不要寫死,不需要重新編쐠…
時間Fri Oct 23 02:05:37 2009
※ 引述《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
推 PsMonkey:什麼「意似」我不知道,想知道就去問香蕉,ㄜ...問 API 10/23 08:07
→ PsMonkey:基於程度(比較值),本篇文章給予「作業文條款」警告 10/23 08:10
推 qrtt1:個別指導請播付費專線 :P 10/23 09:20