0% found this document useful (0 votes)
61 views1 page

Kotlin Basics with Riya

This document contains code snippets demonstrating various Kotlin programming concepts like: 1. Declaring and initializing variables of different data types like Int, Float and reassigning their values. 2. Declaring nullable and non-nullable variables. 3. Printing variables and strings to the console. 4. Comparing values using compareTo() and arithmetic operations like addition, subtraction and multiplication on variables.

Uploaded by

Loving Prateek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views1 page

Kotlin Basics with Riya

This document contains code snippets demonstrating various Kotlin programming concepts like: 1. Declaring and initializing variables of different data types like Int, Float and reassigning their values. 2. Declaring nullable and non-nullable variables. 3. Printing variables and strings to the console. 4. Comparing values using compareTo() and arithmetic operations like addition, subtraction and multiplication on variables.

Uploaded by

Loving Prateek
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

fun main(args: Array<String>) {

println("hello riya i wana kiss you")


println(" hello loving you look so sexy dear")
val a:Int=63636
/* a=477777
here it will give error as we are trying to reassigning it
Now here we are taking variable as var ..
by taking this variable we can change the variable value as many times we
want*/
var bc:Int=5457676 // ----> //This variable is not storing null values
var d:Float=36.63673F
// var d=47847
println("sds"+d)
//if we want that our variable would be able to store null then we will have to
declare like this//
var bb:Int?=535;//THis variable can store null values inside it.Java ke ander
primitive data type me null store nhi kar sakte the but yahan hm kar sakte hn
kyunki ye class hai na ki primitive data type
bb=null;
print(bb)// yahan par null print kar dega ..isee hua ye ki furture me null
pointer exception nhi milega..that is the best thing
print(" hdj "+bb)
var b:Int=737
b=3663
// print(a+b)
var c=353.664F
println("hekke"+c)
/* here we have checked whether it is integer or not */
if(a is Int)
{
println("hey this is integer type")
}
println("hello word"+b)

println("hello world "+a)


// now if we want to compare between two values whether one value is greater
than a or not
// if it is greater than other value compiler will return 1 otherwise it will
return -1
//if both the values are true then it will return 0
println(" "+a.compareTo(b))
// in c/c++ it was strcmp for comparision but here is the compareTO for
comparing the wto numbers..
// print
print(a+b)
var po:Int=23;
var pl:Int=12
println(po+pl) // these are the two methods to add two numbers
println(po.plus(pl))
println(po .minus(pl))
println(po.times(pl))// this is useed for multiplyinfg two numbers ...

You might also like