![]() Open the command prompt window and go to the directory where the program file is saved. Println("Hello, world!") // prints Hello World * This will print 'Hello World' as the output Open notepad and add the following code into it. ![]() Use the following instructions to write a Scala program in script mode. Type the following text to the right of the Scala prompt and press the Enter key − Type in expressions to have them evaluated. If Scala is installed in your system, the following output will be displayed − Open the command prompt and use the following command to open Scala. We can execute a Scala program in two modes: one is interactive mode and another is script mode. Traits are used to define object types by specifying the signature of the supported methods. Traits − A trait encapsulates method and field definitions, which can then be reused by mixing them into classes. An object's state is created by the values assigned to these fields.Ĭlosure − A closure is a function, whose return value depends on the value of one or more variables declared outside this function. It is in methods where the logics are written, data is manipulated and all the actions are executed.įields − Each object has its unique set of instance variables, which are called fields. Methods − A method is basically a behavior. Example − A dog has states - color, name, breed as well as behaviors - wagging, barking, and eating.Ĭlass − A class can be defined as a template/blueprint that describes the behaviors/states that are related to the class. Object − Objects have states and behaviors. ![]() Let us now briefly look into what do class, object, methods and instance variables mean. When we consider a Scala program, it can be defined as a collection of objects that communicate via invoking each other’s methods. The biggest syntactic difference between Scala and Java is that the ' ' line end character is optional. If you have a good understanding on Java, then it will be very easy for you to learn Scala.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |