黑马程序员技术交流社区
标题:
异常的创建题
[打印本页]
作者:
UZI
时间:
2016-10-31 23:38
标题:
异常的创建题
定义一个方法,参数是字符数组,字符, 如果字符在字符数组里面存在.就返回他的第一个索引,不存在,就返回-1;如果这个字符数组==null.
* 抛IllegalArgumentException异常.
public static int getIndex(char[] arr ,char c){
if (arr == null) {
throw new IllegalArgumentException("数组为null");
}
for (int i = 0; i < arr.length; i++) {
if (arr[i] == c) {
return i;
}
}
return -1;
}
作者:
IceLoveInFire丶
时间:
2016-11-1 11:21
自定义异常类,可以
作者:
UZI
时间:
2016-11-1 22:53
IceLoveInFire丶 发表于 2016-11-1 11:21
自定义异常类,可以
感觉很多人都会忽视这个
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2