class Customer(CustNo:Int, CustName:String, Balance:Double){ def this(a:Int,b:String){ this(a,b,100.5) } def this(a:Int){ this(a,"Mac", 200.6) } def this(){ this(124, "Stev", 500.6) } def show(){ println("CustNo: " + CustNo + " CustName: " + CustName + " Banance: " + Balance) } } object HelloWorld{ def main(args:Array[String]){ var c1 = new Customer(501,"Rajesh") c1.show() var c2 = new Customer(502) c2.show() var c3 = new Customer() c3.show() } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more