zoukankan      html  css  js  c++  java
  • 类之基础

    package ClassTest;

    class Students extends myTest
    {
    String address;
    /*public Students(){
    super("张曼玉",60);
    System.out.println("输出Students");
    } */
    public Students(String name,int age,String address){
    super.name = name;
    super.age = age;

    this.address = address;
    System.out.println(super.talk()+" "+this.address);


    }
    }

    public class myTest {
    String name;
    int age;

    public myTest() {
    // TODO Auto-generated constructor stub
    System.out.println("输出myTest");
    }
    public myTest(String name,int age){
    this.name = name;
    this.age = age;
    }

    public String talk(){
    return "姓名: "+this.name+" 年龄: "+this.age;
    }
    /**
    * @param args
    */
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    myTest mt = new myTest();
    mt.name = "张三";
    mt.age = 28;
    System.out.println("名字->"+mt.name+":年龄->"+mt.age);
    Students st = new Students("姚明",35,"上海体育中心");
    /* st.name = "张三2";
    st.age = 28;
    st.address = "上饶银行佳丽商城中心";
    System.out.println("名字->"+st.name+":年龄->"+st.age+":地址->"+st.address); */
    st.talk();
    }

    }

  • 相关阅读:
    实现第三方系统单点登录
    python爬虫
    webot设备motor的api
    webots学习
    python学习算术运算
    python快捷键与命令函数
    python学习构造和析构
    python学习对象相关的bif
    python学习对象:拾遗
    matlab基础知识
  • 原文地址:https://www.cnblogs.com/batman425/p/4075387.html
Copyright © 2011-2022 走看看