实训第一天

1.面向对象

一句话分开,分成几个对象,然后用类实现

public static void main(String args[]){

animal a = new animal();

a.show();

}

public class animal{

private String name;

private int age;

public String getName() {
    return name;
}



public void setName(String name) {
    this.name = name;
}



public int getLeg() {
    return leg;
}



public void setLeg(int leg) {
    this.leg = leg;
}

public void show(){

System.out.println(setname+" "+setage);

}

public aninal(){}

public animal(String name,int age){

this.name=name;

this.age=age;

}

}

2.接口,和借口的实现

public interface DouphinService{

public void call();

}

public class DouphinServiceimpl implements DouphinService{

public void call(){

System.out.println("haitunyin");

}

}

原文地址:https://www.cnblogs.com/chenligeng/p/7835270.html