package com.xt.java.FirstExciple.oop;
public class NokiaPhone {
//成员变量
String name="np001";
float size=3.0f;
//构造方法的比较理解
public NokiaPhone()
{
System.out.println("无参的构造方法");
//类方法(父类)
}
public NokiaPhone(String name)
{
this.name=name;
System.out.println(this.name);
}
public NokiaPhone(String name,float size)
{ this(name);
System.out.println(this.size);
this.size=size;
System.out.println(this.name);
System.out.println(this.size);
}
}
//类方法(子类)
package com.xt.java.FirstExciple.o1p;
import com.xt.java.FirstExciple.oop.NokiaPhone;
//子类或者派生类
public class NokiaPhoneSon extends NokiaPhone {
public NokiaPhoneSon(String name,float size){
super(name,size);
}
}
//主方法
package com.xt.java.FirstExciple.oop;
import com.xt.java.FirstExciple.o1p.NokiaPhoneSon;
public class Main {
public static void main(String[] args)
{
// NokiaPhone np=new NokiaPhone("np002",5.55f);
NokiaPhoneSon nps=new NokiaPhoneSon("np002",5.55f);
}
}