- 博客(57)
- 收藏
- 关注
原创 【JAVA】Catch exception笔记
1.你可以catch多个exceptions,如果有几个要做的操作一样,你甚至可以把他们写在一个里面,这样不仅好看而且运行还会变快,但是这样这个参数e就会变成final了,你就不能在catch里改动他了。那这多个可以有superclass/subclass关系吗try{ code that might throw exceptions} catch (FileNotFoundException | UnknownHostException e){ emergency action for
2022-05-25 21:49:19
1623
原创 【JAVA】Java 抛出exception笔记
1.异常类IOException is checked, other is unchecked.checked就是说检查过了你也发现不了,不是你的错,别的就是要么程序烂了,要么是你写代码时候的问题,比如数组越界,就是说你没检查过,但应该检查的。2.你应该抛出所有checked的异常,不推荐抛出unchecked的3.如果重写方法,重写的子类方法不能抛出更加概括性的异常,但可以抛出更精细的异常4.如果重写方法,父类不抛出异常,那么子类也不应该抛出,如果父类抛出,那么子类可以选择不抛出5
2022-05-25 18:04:02
303
原创 【JAVA】Reflection 笔记
1. Use object.getClass() and class.class to get the Class.note thatgetclass() is for objects, .class is for classes, for example, a class Student, a object sy, we call Student.class and sy.getClass.2.get a class object through forName() method. Like.
2022-05-19 00:07:58
142
原创 【JAVA】Java前两章一些深入理解和问题
1.Person stu = new Student();new了一个student对象,强制转换为了person,因为person是student的父类,所以可以进行2.Person[] stus = new Student[10];左边是定义了一个Person数组,叫做stus,右边是创建了10个null,实际上啥也没干,但是右边必须能类型转换为左边。3.for (Person p : stus) { p = new Teacher(); p.raise
2022-05-17 22:19:14
108
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅