摘要: 子类对象实例化全过程: package com.aff.sup; public class TestDog { public static void main(String[] args) { Dog d = new Dog(); d.setAge(2); d.setName("天天"); d.se 阅读全文
posted @ 2020-03-18 13:20 林淼零 阅读(144) 评论(0) 推荐(0)
摘要: super:可以用来修饰属性 方法 构造器 当子类与父类中有同名的属性时,可以通过 super.此属性 显式的调用父类声明的属性 若想调用子类的同名的属性“this.此属性” 2.当子类重写父类的方法以后,在子类中若想再显式的调用父类的被重写的方法,就需要使用 super.方法 3.super修饰构 阅读全文
posted @ 2020-03-18 11:48 林淼零 阅读(2827) 评论(0) 推荐(0)
摘要: 练习一: ManKind: package com.aff.ex1; //定义一个ManKind类,包括成员变量int sex, int salary //方法 void manOrWoman(); 根据sex的值显示man: sex == 1 , woman:sex == 0 //方法 void 阅读全文
posted @ 2020-03-18 10:19 林淼零 阅读(294) 评论(0) 推荐(0)
摘要: 1.面向对象的特征:继承性 2.通过 Class A extends B 实现类的继承 子类:A 父类(基类 SuperClass):B 3.子类继承父类后,父类声明的属性 方法,子类就可以获取到。 注意:当父类中有私有的属性或者方法时,子类是可以获取的到,只是由于封装性的设计 使得子类不能直接调用 阅读全文
posted @ 2020-03-18 09:49 林淼零 阅读(176) 评论(0) 推荐(0)
摘要: Account: package com.aff.ex; public class Account { private int id;// 账号 private double balance;// 余额 private double annualInterestRate;// 年利率 public 阅读全文
posted @ 2020-03-18 03:06 林淼零 阅读(191) 评论(0) 推荐(0)
摘要: this: 1.可以用来修饰属性 方法 构造器 2.this理解为当前对象或当前正在创建的对象、 3.可以在构造器中通过this()形参的方式显示的调用本类中其他重载的指定的构造器 要求: 在构造器内部必须申明在首行 若一个类中有n个构造器, 那么最多只能有 n-1 个构造器中使用 this(形参) 阅读全文
posted @ 2020-03-15 23:10 林淼零 阅读(176) 评论(0) 推荐(0)
摘要: Account: package banking4; public class Account { private double balance; public Account(double int_balance) { balance = int_balance; } public double 阅读全文
posted @ 2020-03-13 17:36 林淼零 阅读(258) 评论(0) 推荐(0)
摘要: Account: package banking3; //账户 public class Account { private double balance;// 账户余额 public Account(double init_balance) { balance = init_balance; } 阅读全文
posted @ 2020-03-13 16:45 林淼零 阅读(174) 评论(0) 推荐(0)
摘要: Account: package banking2; //账户 public class Account { private double balance;// 账户余额 public Account(double init_balance) { balance = init_balance; } 阅读全文
posted @ 2020-03-13 13:04 林淼零 阅读(151) 评论(0) 推荐(0)
摘要: Bank1: package banking1; //账户 public class Account { private double balance;// 账户余额 public Account(double init_balance) { balance = init_balance; } pu 阅读全文
posted @ 2020-03-13 12:41 林淼零 阅读(202) 评论(0) 推荐(0)