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

object HelloWorld {
   def main(args: Array[String]) {
      val constant = 87
      val myList = List(2, 4, 6,8,10,12)
      val kv :: kovi :: thanooj = myList
      var first = kv
      println("myFirstFunctiom  :  "+ myFirstFunctiom(first.toString))
      println("myStringFunction :  "+  myStringFunction)
      println("MaxFunction      :  "+ max(1,2))
      
       listOfmultiType(1)
       listOfmultiType("hi")
      println( myList.foldLeft(0) { (a ,b)=>  a+b })
      println( myList.foldLeft(0) { ( _ + _ )})
      val hasUpperCase = myStringFunction.exists(_.isUpper)
      println("hasUpperCase      :  "+ hasUpperCase)
      install
      myList.foreach(print)
    
   }
   def myFirstFunctiom(data:String) :String = {
       return data
   }
   def myStringFunction() ="this is the sample text from myStringFunction"   
   def max(a:Int,b:Int) :Int = {
       if(a>b)  a else b
   }
   def listOfmultiType[CustomType] (value:CustomType) =List(value)
   def break = new RuntimeException("break exception")
   def install = {
       val env = System.getenv("SCALA_HOME")
       if(env == null) break
       println("found the scala home lets countinue the operation")
   }
  
}

Advertisements
Loading...

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