摘要:
构造方法 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;// 阅读全文
摘要:
集合 集合中常用方法 public static void main(String[] args) { //创建ArrayList集合 ArrayList list=new ArrayList(); ArrayList plist=new ArrayList(); boolean flag=list.add(1);//添加... 阅读全文
摘要:
方法 方法的语法格式 public static void main(String[] args) { //方法调用 double area=getArea(1.2); System.out.println(area); } /*修饰符 返回值类型 方法名(参数类型 参数名1,参数类型 参数名2,......){ ... 阅读全文