看板 java 關於我們 聯絡資訊
※ 引述《coolcomm (coolcomm)》之銘言: : http://ppt.cc/ZbBl : 24: : int number=Integer.parseInt(Pattern.compile("\\d*").matcher(capacity).group()); : 請問為什麼每次到了第24行就會拋出IllegalStateException? : 剛剛把這行分開來寫 結果更奇怪了 : Pattern pattern=Pattern.compile("\\d*"); //在這行就拋出IllegalStateException : 有人知道是發生什麼事嗎@@ 呃... 推文是我搞錯... 去看一次 API Matcher.group() : Returns the input subsequence matched by the previous match. 而 Pattern.matcher() method 回傳的 Matcher 物件, 是未曾開始進行 match 動作的 所以你的那段 code 會一直 return IllegalStateException: No match found. 至於怎樣才能讓 matcher 跑起來.... 再去看看 API 文件吧. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 147.8.127.102
coolcomm:Creates a matcher that will match the given input 10/29 19:58
coolcomm:against this pattern. 10/29 19:59
coolcomm:這是Pattern.matcher()的解釋 10/29 20:00
superlubu:"will" match... 不過你不相信就算了吧。 10/29 23:04