Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Scala Online

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()
    }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.