Tho*_*ley 6 java regex static-variables
我在课堂上有以下方法:
public boolean validTransAmt()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
Pattern p = Pattern.compile("^([0-9]{0,})(([\\.]?)([0-9]{1,2})([\\.]?))$");
String transAmt = getDetails().getAmount();
Matcher matcher = p.matcher(transAmt);
if (!matcher.matches())
{
...
}
...
}
Run Code Online (Sandbox Code Playgroud)
每次调用该方法时,是否会重新编译此模式?或者它是否被缓存?
我应该在班上将它声明为静态变量吗?
谢谢
| 归档时间: |
|
| 查看次数: |
224 次 |
| 最近记录: |