1.异常
public class YiChang {
public static void main(String[] args) throws CustomCheckedException {
int a = 0;
if(a1) {
throw new CustomCheckedException(“参数”);//先打下面这段代码点击提示
}
if(a0) {
throw new CustomRuntimeException();
}
}
}
class CustomCheckedException extends Exception{
public CustomCheckedException() {
super(“自定义Check异常信息”);
}
public CustomCheckedException(String msg) {
super(msg);
}
}
class CustomRuntimeException extends RuntimeException{
public CustomRuntimeException() {
super(“自定义Runtime异常信息”);
}
public CustomRuntimeException(String msg) {
super(msg);
}
}
2.顺序
//不用返回值 Void
public class ShunXu {
public static void main(String[] args) {
List list = new ArrayList();//integer整数包装类
list.add(2616);
list.add(745);
list.add(456);
list.add(123);
System.out.println(list);
//收集 Collections
//倒叙 reverse
Collections.reverse(list);
System.out.println(list);
//随机顺序 shuffle
Collections.shuffle(list);
System.out.println(list);
//正序 sort
Collections.sort(list);
System.out.println(list);
try {
int a=0;
int b=1/a;
}
catch (Exception e) {
e.printStackTrace();//打印堆A栈信息 printStackTrace
}
finally {
System.out.println("finallys");
}
System.out.println("end");
}
//throw 抛出一个异常 throws 声明在该定义方法抛出所有异常
//需要返回值
private static int intDivide(String[] args) {
int c = 0;
return c;
}
}