//Demo package p1.
package p1;
//Instantiate the various classes in p1.
public class DemoP
{
    public static void main(String[] args)
    {
        Protection ob1 = new Protection();
        Derived ob2 = new Derived();
        SamePackage ob3 = new SamePackage();
    }
}
chujinxin(前端大神) - 2019-10-25 0 人
DemoP
//Demo package p1.
package p1;
//Instantiate the various classes in p1.
public class DemoP
{
    public static void main(String[] args)
    {
        Protection ob1 = new Protection();
        Derived ob2 = new Derived();
        SamePackage ob3 = new SamePackage();
    }
}
daomeixuelei(前端大神) - 2019-09-28 0 人
DemoP
package p1;
class SamePackage
{
    SamePackage()
    {
        Protection p = new Protection();
        System.out.println("same package constructor");
        System.out.println("n = " + p.n);
        //class only
        //System.out.println("n_pri = " + p.n_pri);
        System.out.println("n_pro = " + p.n_pro);
        System.out.println("n_pub = " + p.n_pub);
    }
}
daomeixuelei(前端大神) - 2019-09-28 0 人
Samepackage
package p1;
class Derived extends Protection
{
    Derived()
    {
        System.out.println("derived constructor");
        System.out.println(" n = " + n);
        //class only
        //System.out.println("n_pri = " + n_pri);
        System.out.println("n_pro = " + n_pro);
        System.out.println("n_pub = " + n_pub);
    }
}
daomeixuelei(前端大神) - 2019-09-28 0 人
Derived
package p1;
class Protection
{
    int n =1;
    private int n_pri = 2;
    protected int n_pro = 3;
    public int n_pub = 4;
    public Protection()
    {
        System.out.println("base constructor");
        System.out.println("n = " + n);
        System.out.println("n_pri = " + n_pri);
        System.out.println("n_pro = " + n_pro);
        System.out.println("n_pub = " + n_pub);
    }
}
daomeixuelei(前端大神) - 2019-09-28 0 人
Protection
class Main {
	public static void main(String[] args) {
        //程序运行完成时一定要有输出语句,本工具才能正确展示运行结果。
		System.out.println("Hello JSRUN!   \n\n         - from JAVA .");
	}
}
daomeixuelei(前端大神) - 2019-09-28 0 人
Package1
没有了
1/36 下一页