Package zhj_test;
public class Point {public Point () {//todo} (string Name, string address) {this.aname = name;
point.aaddress = address;
Public String toString () {return This.getclass (). GetName () + "[" + getName () + "," + point.aaddress + "]";
public void SetName (final String name) {this.aname = name;
Public String GetName () {return aname;
Private String Aname;
public static String aaddress;
static {aaddress = "BeiJing";
} {aname = "ASDFASDFASFADSF";
public static void print (Object obj) {System.out.println (obj);
public static void Main (string[] args) {point P = new Point ();
Point.print (P);
Point P1 = new Point ("Yoyo", "Shenyang");
Point.print (P);
Point.print (p1);
Person[] PS = new person[2];
Ps[0] = new Manager ("Zhj", "Beijing", "1010", 32);
PS[1] = new Employee ("Test", "Beijing", "1010", 6);
for (person S:ps) {System.out.println (s.tostring ());The abstract public static class person {public person () {} public person (int age) {Thi
S.setage (age);
Public abstract String getName ();
Public abstract String getaddress ();
Public abstract String GetCode ();
Public abstract String toString ();
public int getage () {return age;
public void Setage (int age) {this.age = age;
private int age; public static class Manager extends person {public Manager () {//todo} public Manager (String name,
string address, string code, int age) {super.setage (age);
This.aname = name;
this.aaddress = address;
This.acode = code;
Public String GetName () {return aname;
Public String getaddress () {return aaddress;
Public String GetCode () {return acode; Public String toString () {return This.getclass (). GetName () + "[name=" + this.getname () + ", age=" + this.get Age () + ", address=" + This.getaddRess () + ", code=" + this.getcode ();
Private String Aname;
Private String aaddress;
Private String Acode; public static class Employee extends person {public employee () {//todo} public employee (String name
, string address, string code, int age) {super.setage (age);
This.aname = name;
this.aaddress = address;
This.acode = code;
Public String GetName () {return aname;
Public String getaddress () {return aaddress;
Public String GetCode () {return acode; Public String toString () {return This.getclass (). GetName () + "[name=" + this.getname () + ", age=" + this.getage
() + ", address=" + this.getaddress () + ", code=" + this.getcode ();
Private String Aname;
Private String aaddress;
Private String Acode;
}
}
Description
The implementation of the 1> inner class is shown in the code above, because in Java, static methods in a class cannot invoke dynamic methods directly. Only the inner class is decorated as a static class (public static * * *), and then the member variable and member method of the class can be called in the static class.
2> abstract class: Keyword abstract (the top of the superclass, and the abstract method in the superclass must contain this keyword),
Way:
Abstract classes: Abstract class * * *.
Abstract method: Public Abstract String * * * * * ...
Subclasses must implement all of the abstract methods.