package base.class1; public class Stu { String name; public void greeting() { System.out.println("hi,there."); } }
package base.class1; public class OOP { public static void main(String[] args) { Stu stu = new Stu(); stu.name = "gl"; System.out.println(stu.name); stu.greeting(); } }
package base.class1; public class Stu { public Stu() { } }
package base.class1; public class Stu { public Stu(String str) { this.name = str; } }
public class Stu extends Person { // ... ... }
public class Duck extends Ani{ String name="duck"; public void barking(){ String name="barking animal"; System.out.println("name: "+name); System.out.println("name: "+this.name); System.out.println("name: "+super.name); } }
package basic.superUse; class Ani{ public Ani(){ System.out.println("Ani()"); } } class Bird extends Ani{ public Bird(){ System.out.println("Bird()"); } } public class SuperDemo { public static void main(String[] args) { Bird bird=new Bird(); } }
Animal animal = new Cat(); animal.eat();