【发布时间】:2016-08-09 15:09:50
【问题描述】:
String replaceSubString(String orignal, int startIndex, int endIndex, String replaceWith){
StringBuffer buffer = new StringBuffer(orignal);
if ((action.getEndindex() - action.getStartindex()) < 0) {
if (replaceWith.length() > (startIndex - endIndex)) {
throw new RuntimeException("Replace string lenght not same as difference of start & end index.");
}
buffer = buffer.replace(endIndex, startIndex, replaceWith);
} else {
if (replaceWith.length() > (endIndex - startIndex)) {
throw new RuntimeException("Replace string lenght not same as difference of start & end index.");
}
buffer = buffer.replace(startIndex, endIndex, replaceWith);
}
return buffer.toString();
}
嗨,这是我的代码,当我检查它的代码质量时,它显示“定义并抛出一个专用异常而不是使用通用异常”我应该怎么做才能解决这个问题?谁能帮我解决这个问题。
【问题讨论】:
-
修复lenght的拼写。这会改善我的心情,我会发布答案。