scala基础(2) --class constructor

class GFG(Lname: String, Tname: String, article: Int)  
{  
    def show()  
    {  
        println("Language name: " + Lname);  
        println("Topic name: " + Tname);  
        println("Total published articles:" + article);  
    }  
}  
object Main  
{  
    // Main method 
    def main(args: Array[String])  
    {  
          
        // Creating and initialzing  
        // object of GFG class  
        var obj = new GFG("Scala", "Constructors", 14);  
        obj.show();  
    }  
}  

猜你喜欢

转载自www.cnblogs.com/pocahontas/p/11405708.html