There are two types of variables – mutable and immutable. An immutable variable is one whose value cannot be changed, also known as unchangeable or read-only variable. On the other hand the value of the mutable variable can be changed. Immutable variable: val keyword Immutable variable is declared using val keyword in Kotlin. In this example, we have declared an immutable variable myName using val keyword and later displayed the value of it. package tejprogramming fun main(args : Array<String>){ /** * This is an immutable variable * also called unchangeable variable * or read-only variable. */ val myName = "Suvidha" println("My Name is: "+myName) } …
-
-
In java boolean datatype is used to take value true or false. This is the type that is returned by all relational operators, as in the case a<b. boolean is also required by conditional expressions that govern the control statement such as if and for. In previous we learn about primitive datatype which give introduction of basic java’s data type. We know that boolean only take the value either true or false. Unlike in C where the boolean also takes 0 and 1 to determine false and, true this is the not case in java. Example The below example shows…