java——接口的实现

2019年2月16日11:01:38 发表评论 945 views
/**
 * Created by xabcd on 2019/2/16.
 */
interface  java_jiekou1
{
    String name = "张三";
    int age = 25;
    String occupation = "学生";
    public abstract String talk();
}
class Student5 implements java_jiekou1
{
    //覆写talk()方法
    public String talk()
    {
        return "学生——》姓名:"+this.name+"年龄:"+this.age+"职业:"+this.occupation;
    }
}








/**
 * Created by xabcd on 2019/2/16.
 */
public class test_jiekou1
{
    public static void main(String[] args)
    {
        Student5 s =new Student5();
        System.out.println(s.talk());
    }
}





结果:
学生——》姓名:张三年龄:25职业:学生

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: