Re: [問題] 字串比較的問題
※ 引述《jgpnsgm (哼!)》之銘言:
public static int findStringInArray(String cmd, String[] array){
for(int i=0; i<array.length; i++){
if(array[i].equal(cmd)){
return i;
}
}
return -1;
}
//somewhere in your need
switch(findStringInArray("XD", commandSet)){
case COMMAND.XD:
callXDProcedure();
}
//好像是在 Programming Pearl 這本書看到的方法
//應該最符合原 po 吧?
//至於 tkcn 那種... 仰之彌高... [遠目]
--
侃侃長論鮮窒礙 首頁:http://www.psmonkey.idv.tw
眾目睽睽無心顫 Blog:http://ps-think.blogspot.com
煢居少聊常人事
殺頭容易告白難 歡迎參觀 Java 版(@ptt.cc)精華區 \囧/
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.195.92
討論串 (同標題文章)
完整討論串 (本文為第 4 之 8 篇):