-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ScalaBasic | ||
|
||
// https://www.youtube.com/watch?v=EeN3v0zAsgg&list=PLmOn9nNkQxJEqCNXBu5ozT_26xwvUbHyE&index=80 | ||
|
||
object SuperConstruct extends App { | ||
|
||
// run 1 | ||
val emp = new Employer_5("tom") | ||
println(emp.name) | ||
|
||
println("---------------------") | ||
|
||
// run 2 | ||
val emp2 = new Employer_5() | ||
println(emp2.name) | ||
} | ||
|
||
// Person_5 is Employer_5's father class | ||
// Person_5's default main constructor is Person_5() | ||
class Person_5 { | ||
var name = "kyo" | ||
println("Person_5 ....") | ||
} | ||
|
||
// Employer_5 is Person_5's children class | ||
// Employer_5's default main constructor is Employer_5() | ||
class Employer_5 extends Person_5 { | ||
def this(name: String){ | ||
this // have to call main constructor at beginning | ||
this.name = name | ||
println("Employer_5 ....") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package ScalaBasic; | ||
|
||
// 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 ..."); | ||
|
||
} | ||
} | ||
|
||
class A_java { | ||
public A_java(){ | ||
System.out.println("A()"); | ||
} | ||
public A_java(String name){ | ||
System.out.println("A(String name)" + name); | ||
} | ||
} | ||
|
||
class B_java extends A_java{ | ||
public B_java(){ | ||
// here java will "implicitly" use super(), | ||
// i.e. A_java() (without param) | ||
System.out.println("B()"); | ||
} | ||
|
||
public B_java(String name){ | ||
super(name); | ||
System.out.println("B(String name)" + name); | ||
} | ||
} |