?java类的继承2

2019年2月15日22:42:31 发表评论 1,757 views
import java.util.SplittableRandom;

/**
 * Created by xabcd on 2019/2/15.
 */
public class java_jicheng
{


    public class jicheng {
        String name;
        int age;
    }
    class Student2 extends jicheng{
        String school;
    }



    public static void main(String[] srgs)
    {
        Student2 s = new Student2();//无法从静态上下文引用非静态变量
        s.name = "张三";
        s.age = 25;
        s.school = "北京";
        System.out.println("姓名"+s.name+",年龄:"+s.age+",学校:"+s.school);
    }
}

发表评论

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