摘要:
final关键字 public class Test { public static void main(String[] args) { //final 修饰局部变量 (基本数据类型) //一旦赋值终身不变 final int i; i=1;//只能赋值一次 //final 修饰局部变量 (引用数据类型) ... 阅读全文
摘要:
构造方法 public class Person { private String name; private int age; //默认构造方法 public Person(){ System.out.println("这是Person的空参构造"); } public Person(){ //调用本类的构造方法 ... 阅读全文
摘要:
多态 public class Fu { int a=1; public void methed(){ System.out.println("这是父类"); } } public class Zi extends Fu{ int a=2; public void methed(){ System.out.println(... 阅读全文
摘要:
接口与方法实现 关键字interface implements public interface Smoking { public abstract void smoke(); } public class Dog implements Smoking{ public void smoke(){ System.out.println("我套你猴子");... 阅读全文
摘要:
普通方法的继承 public class Emp { String name; int age; public void work(){ System.out.println("员工正在工作"); } } //维护部员工继承自员工 public class WeiHu extends Emp{ //自己的方法 public void spe... 阅读全文
摘要:
//成员变量和局部变量 //1.在定义上:成员变量定义在类中,局部变量定义在方法中或块中 public class Student { //成员变量 String name; int age; String sex; //成员方法 public void study(){ int book=0;// 阅读全文