Skip to content
KUSHA B K edited this page Jul 3, 2016 · 4 revisions

Scala Programming

Learn scala in simple way

#List of Scala Keywords

          @
          #
          >:
          <%
          <:
           <-
           =>
           =
           :
           -
    abstract
    case
    catch
    class
    def
    do
    else
    extends
    false
    final
    finally
    for
    forSome
    if
    implicit
    import
    lazy
    match
    new
    Null
    object
    override
    package
    private
    protected
    return
    sealed
    super
    this
    throw
    trait
    Try
    true
    type
    val
    Var
    while
    with
    yield

How to comment in scala

type 1 :

       /** This is a comment in scala defined autor kusha b k **/

type 2 :

     // this line  is comment in scala defined by autor 

#How to import package in scala

type 1:

                import kushabk._          

type 2:

                import kusha.b

type 3:

                import kusha.b.k        

type 4:

                import kusha.{b,k}

#How to define mutable variables in scala

#1. How to define integer variables in Scala

syntax 1

    var Int_variable_name

Syntax 2

    var Int_variable_name = initialization_value 

examples

 var myIntvalue


 var myIntvalueInit = 100

##2. How to define Double variables in Scala

syntax 1

    var double_variable_name

Syntax 2

    var double_variable_name = initialization_value 

examples

 var mydoubletvalue


 var mydoublevalueInit = 100.0

##3. How to define Floating variables in Scala

syntax 1

    var float_variable_name

Syntax 2

    var float_variable_name = initialization_value 

examples

 var myfloat


 var myfloatvalueInit = 100.0f

##4. How to define String variables in Scala

syntax 1

    var string_variable_name

Syntax 2

    var string_variable_name = "initialization_value" 

examples

 var mystring


 var mystringvalueInit = "Hellow String world by kusha"

##5. How to define Character variables in Scala

syntax 1

    var char_variable_name

Syntax 2

    var char_variable_name = 'initialization_value '

examples

 var mychar


 var mycharvalueInit = 'K'

#How to print out put in scala

    println("This is my output")

#Defining The function in scala def thisismyfunctionname(myintvariable: Int) = { myintvariable * myintvariable }

Clone this wiki locally