Guys/Girls I am using Eclipse IDE for Scala for development
You can easily download this from below URL
http://scala-ide.org/download/current.html
Now lets start with our first example.As usual it Hello World program.
Please follow below steps to create and execute first class
Step:1)GO to file =>New=>Select "Scala Class"
Step:2)Give name as HelloWorld.scala
Step:3) Inside Class use method println to write hello world.
code will look like
class HelloWorldWithObject {
println("Hello World");
}
Step:4)Extend this class with App trait
NOte:What IS App trait,Below is small documentation of App
scala.App
The App trait can be used to quickly turn objects into executable programs. Here is an example:
object Main extends App {
Console.println("Hello World: " + (args mkString ", "))
}
Here, object Main inherits the main method of App.
args returns the current command line arguments as an array.
Step:5)Complete class will look like
package com.sagar.basic
class HelloWordlWithApp extends App {
println("Hello World");
}
Step:6) Right click inside class and run it as scala application it will print below output:
Hello World
You can easily download this from below URL
http://scala-ide.org/download/current.html
Now lets start with our first example.As usual it Hello World program.
Please follow below steps to create and execute first class
Step:1)GO to file =>New=>Select "Scala Class"
Step:2)Give name as HelloWorld.scala
Step:3) Inside Class use method println to write hello world.
code will look like
class HelloWorldWithObject {
println("Hello World");
}
Step:4)Extend this class with App trait
NOte:What IS App trait,Below is small documentation of App
scala.App
The App trait can be used to quickly turn objects into executable programs. Here is an example:
object Main extends App {
Console.println("Hello World: " + (args mkString ", "))
}
Here, object Main inherits the main method of App.
args returns the current command line arguments as an array.
Step:5)Complete class will look like
package com.sagar.basic
class HelloWordlWithApp extends App {
println("Hello World");
}
Step:6) Right click inside class and run it as scala application it will print below output:
Hello World
No comments:
Post a Comment