Member-only story
Kotlin for Android Development: A Complete Beginner’s Guide 🚀
In this article we will see a complete beginner’s guide to start with the Android Development.
🚀 Variables
In kotlin variables are declared using val
, var
and const
keywords
🔴 val
Variables declared with val
cannot be reinitialised further , it should be initialised at the time of declaration.
val name:String = "Jayant"
If we try to re-initialised then we will get the compile time error.
🔴 var
Variables declared with var
can be reinitialised later.
var name1 = "Jayant"
name1 = "Mohan"
🔴 const
const
keyword is used to declare constant values, if the value is fixed , not dynamic then we should declare variables with const
.
const val name = "Hello const value"
const val PI = 3.14
🚀 Data Types
We can also define the data type to each variables , so that it does not accept any other type.
🔴 String
val name:String = "Jayant"
🔴 Int
val num:Int = 12