<>scala Sample class

code
// Sample class object CaseDemo { def main(args: Array[String]): Unit = { // Defining sample classes
// The default parameter of the constructor is public case class Message( var sender:String,recipient:String ,body:
String) // Create an object for the sample class val messagel=Message("Jerry","Tom","Hello") println("sender:"
+messagel.sender) println("recipient:"+messagel.recipient) messagel.sender="Bob"
//sender use var It can be output when decorated println("sender2:"+messagel.sender)
//messagel.recipient="sss"//recipient Default use val modification } }
result
sender:Jerry recipient:Tom sender2:Bob Process finished with exit code 0

Technology