Created
August 3, 2013 04:35
-
-
Save lu911/6145204 to your computer and use it in GitHub Desktop.
Assistance Constructor
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
object Main { | |
def main(args: Array[String]): Unit = { | |
val p1 = new Person | |
val p2 = new Person("Loup") | |
val p3 = new Person("Loup", 19) | |
} | |
class Person | |
{ | |
private var name = "" | |
private var age = 0 | |
def this(name: String) | |
{ | |
this() | |
this.name = name | |
} | |
def this(name: String, age: Int) | |
{ | |
this(name) | |
this.age = age | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment