62,621
社区成员
发帖
与我相关
我的任务
分享
private final static List<String> nowords = new ArrayList<String>(){
{
// 初始化块
try{
addAll(IOUtils.readLines(SearchHelper.class.getResourceAsStream("/stopword.dic")));
}catch(IOException e){
log.error("Unabled to read stopword file", e);
}
}
};
private final static List<String> nowords = new ArrayList<String>(){{
try{
addAll(IOUtils.readLines(SearchHelper.class.getResourceAsStream("/stopword.dic")));
}catch(IOException e){
log.error("Unabled to read stopword file", e);
}
}};
是不是等同于
private final static List<String> nowords = new ArrayList<String>();
static {//静态初始化块
try{
nowords.addAll(IOUtils.readLines(SearchHelper.class.getResourceAsStream("/stopword.dic")));
}catch(IOException e){
log.error("Unabled to read stopword file", e);
}
}