摘要: public class Demo01 { public static void main(String[] args) { int a =1; int b =0; //ctrl+alt+T //假设要捕获多个异常:从小到大 try {//监控区域 new Demo01().a(); } catch 阅读全文
posted @ 2024-01-23 11:58 fightownself 阅读(1) 评论(0) 推荐(0) 编辑
摘要: public class Outer { private int id =10; public void out(){ System.out.println("这是外部类的方法"); } public class Inner{ public void in() { System.out.printl 阅读全文
posted @ 2024-01-23 10:50 fightownself 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 接口的本质就是契约 作用: 约束 定义一些方法,让不同的人实现 public abstract public static final 接口不能实例化,接口中没有构造方法 implements可以实现多个接口 必须重写接口中的方法 //定义的关键字 interface ,接口都需要有实现类publi 阅读全文
posted @ 2024-01-23 10:09 fightownself 阅读(2) 评论(0) 推荐(0) 编辑
摘要: //抽象类 类:extends:单继承 接口可以多继承public abstract class Action { //abstract 抽象方法 只有方法名字,没有实现的效果 public abstract void doSomething(); //1.不能new这个抽象类,只能靠子类去实现它: 阅读全文
posted @ 2024-01-19 15:14 fightownself 阅读(2) 评论(0) 推荐(0) 编辑
摘要: public class Application { public static void main(String[] args) { //Object >String //Object >Person>Student //Object >Person>Teacher //System.out.pr 阅读全文
posted @ 2024-01-18 17:48 fightownself 阅读(2) 评论(0) 推荐(0) 编辑
摘要: public class Application { public static void main(String[] args) { //一个对象的实际类型是确定的 //可以指向的引用类型就不确定了:父类的引用指向了子类 //Student 能调用的方法都是自己的或者继承父类的 Student s 阅读全文
posted @ 2024-01-18 10:58 fightownself 阅读(3) 评论(0) 推荐(0) 编辑
摘要: super注意点 super调用父类的构造方法,必须在构造方法的第一个 super必须只能出现在子类的方法或者构造方法中 super和this 不能同时调用构造方法 this 代表的对象不同: this :本身调用者这个对象 super:代表父类对象的应用 前提 this:没有继承也可以使用 sup 阅读全文
posted @ 2024-01-17 16:52 fightownself 阅读(2) 评论(0) 推荐(0) 编辑
摘要: super注意点 super调用父类的构造方法,必须在构造方法的第一个 super必须只能出现在子类的方法或者构造方法中 super和this 不能同时调用构造方法 this 代表的对象不同: this :本身调用者这个对象 super:代表父类对象的应用 前提 this:没有继承也可以使用 sup 阅读全文
posted @ 2024-01-17 11:58 fightownself 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 继承 //java中所有的类,都默认继承直接或者间接继承object//Person :人 父类//java中只有单继承没有多继承public class Person { private int money = 10_0000_0000;​ public int getMoney() { retu 阅读全文
posted @ 2024-01-17 10:35 fightownself 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 属性私有,get/set public class Application { public static void main(String[] args) { /* * 1.提高程序的安全性,保护数据 * 2.隐藏代码的实现细节 * 3.统一接口 * 4.提高了系统的维护性 * */ Studen 阅读全文
posted @ 2024-01-16 16:50 fightownself 阅读(3) 评论(0) 推荐(0) 编辑