Saturday, April 7, 2012

Scala Basics - Simple Class

Simple class definition
scala> class User {
   val userName:String ="Steve Kent"
   def getUserName(firstName: String, lastName:String): String = firstName + " " + lastName
 defined class User

Define object of the Class
scala> scala> var user = new User
user: User = User@1fce2f2

Access Class members through Object
scala> scala> scala> user.getUserName("sam","anderson")
res1: String = sam anderson

No comments:

Post a Comment