Last active
May 7, 2021 09:58
-
-
Save channyeintun/aa75fac723d7b08b4fcae0b542eda0cf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package main | |
| class Constructors(val color:String){ | |
| init { | |
| println("Init Color=$color") | |
| } | |
| //val or var is not allowed on secondary constructors | |
| //You cannot declare a return type for a secondary constructor | |
| constructor(color:String,value:Int):this(color){ | |
| println("Color=$color,Value=$value") | |
| } | |
| fun showColor():Unit{ | |
| println("Color is $color") | |
| } | |
| } | |
| fun main(){ | |
| val test:Color=Color("Red",12) | |
| test.showColor() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment