Skip to content

Commit

Permalink
update SuperConstruct1_java.java
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Feb 11, 2021
1 parent 7ac4de4 commit 19adebb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/scala/ScalaBasic/SuperConstruct1_java.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@

// https://www.youtube.com/watch?v=EeN3v0zAsgg&list=PLmOn9nNkQxJEqCNXBu5ozT_26xwvUbHyE&index=80

import com.sun.tools.internal.ws.wsdl.document.soap.SOAPUse;

public class SuperConstruct1_java {
public static void main(String[] args){
System.out.println("SuperConstruct1 ...");

// run
B_java b = new B_java();

// run 2
B_java b_2 = new B_java("tim cat");
}
}

// parent class
class A_java {
// constructor without param
public A_java(){
System.out.println("A()");
}
// constructor with param
public A_java(String name){
System.out.println("A(String name)" + name);
}
}

// children class
class B_java extends A_java{
// constructor without param
public B_java(){
// here java will "implicitly" use super(),
// i.e. A_java() (without param)
//super();
System.out.println("B()");
}

// constructor with param
public B_java(String name){
super(name);
System.out.println("B(String name)" + name);
Expand Down

0 comments on commit 19adebb

Please sign in to comment.