摘要: public class Test { public static void main(String[] args) { int a=1; int b=0; new Test().c(1,0); try{//try 监控区域 System.out.println(a/b); }catch(Excep 阅读全文
posted @ 2025-07-12 17:11 萧xiao 阅读(7) 评论(0) 推荐(0)
摘要: //外部类 public class Outer { public class inner{ }//成员内部类 public static void main(String[] args) { class Inner{ }//局部内部类 //没有名字的初始化, 不用将实例保存到变量中 new inn 阅读全文
posted @ 2025-07-12 15:46 萧xiao 阅读(4) 评论(0) 推荐(0)
摘要: 接口一: //interface 定义的关键字 , 接口都需要实现类 public interface UserService { //接口里的属性都行静态的常量 int age=10; public static final int age2=20; //接口里定义的方法都是抽象的 public 阅读全文
posted @ 2025-07-12 15:20 萧xiao 阅读(7) 评论(0) 推荐(0)
摘要: //abstract 抽象类 public abstract class Action { //约束,有人帮我们实现(给子类实现) //abstract,抽象方法,只有方法名字,没有方法的实现 public abstract void xxx(); //注意 //1.不能new这个抽象类,只能靠子类 阅读全文
posted @ 2025-07-11 21:30 萧xiao 阅读(9) 评论(0) 推荐(0)
摘要: public class Application { //static 是和类一起加载的 static int a ; //静态的方法是和类一起加载的 int b ; public static void main(String[] args) { System.out.println(Applic 阅读全文
posted @ 2025-07-11 21:02 萧xiao 阅读(9) 评论(0) 推荐(0)
摘要: //Object > Person > student //Object > Person > Teacher //instanceof 判断是否为父子类 //System.out.println(x instanceof y);//能不能被成功编译,能的话则有关,不能的话则无关 Student s 阅读全文
posted @ 2025-07-11 17:26 萧xiao 阅读(13) 评论(0) 推荐(0)
摘要: public class Application { public static void main(String[] args) { //一个对象的实际类型是确定的 //new Student(); //new Person(); //但是可以指向的引用类型就不确定了 Student s1 = n 阅读全文
posted @ 2025-07-11 17:24 萧xiao 阅读(12) 评论(0) 推荐(0)
摘要: 父类: public class b { public void a(){ System.out.println("b"); } } 子类: public class a extends b { public void a(){ System.out.println("a"); } } 执行类: p 阅读全文
posted @ 2025-07-10 21:09 萧xiao 阅读(11) 评论(0) 推荐(0)
摘要: 父类: public class Person1 { //常用前缀 // public; 公共的 // private; 私有的 // protected; 受保护的 // default; 默认的 protected String name="xiao"; public void print(){ 阅读全文
posted @ 2025-07-10 16:43 萧xiao 阅读(11) 评论(0) 推荐(0)
摘要: 父类: public class Person { private String name;//private的属性子也不能用 public int money = 1_0000_0000; public void say(){ System.out.println("说了一句话"); } } 子类 阅读全文
posted @ 2025-07-10 15:34 萧xiao 阅读(9) 评论(0) 推荐(0)