Category Archives: Kotlin

encapsulation in Kotlin

Encapsulation in Kotlin: //Link of my previous tutorial about Object oriented programming in Kotlin . Complete below part first to better understand // Kotlin OOP part 1 Kotlin OOP part 2 Kotlin OOP part 3 Kotlin OOP part 4 There are four visibility modifiers in Kotlin. private, protected, internal and public. We learn every part step by step… Read More »

Object Oriented Programming Kotlin (Part:04)

Object Oriented Programming Kotlin (Part:04) OOP in kotlin is one of the most important topic in kotlin language. We will refactoring our code, in this part of this tutorial. If you see our below code we refactor our code in OOP way but line is not reduce. So we need more refactoring our code. Another note: Create object… Read More »

Object Oriented Programming Kotlin (Part:03)

Object Oriented Programming Kotlin (Part:03)

  note: some important note of Kotlin that is filed level data or property has no default value in kotlin so we need to set initialize value of every field level data In Kotlin method write using fun keyword .  similar others programming language method must be has a return type or… Read More »

Object Oriented Programming in Kotlin (Part:02)

Object Oriented Programming in Kotlin (Part:02) In previous part, we already had discuss why object oriented programming in kotlin is needed then started discussion about kotlin Class, kotlin Object.  Every object has two parts: has: “has” means which element present in this object does(): “does” means which work is done. In this part, we will try to solve our previous problem… Read More »

Object Oriented Programming Kotlin (Part:01)

Object Oriented Programming Kotlin (Part:01) Kotlin language supports OOP (Object Orientated Programming). Before writing any OOP code we first need to know why object oriented programming in kotlin is needed. We can solve any type of problem using procedural oriented way. So why we learn object oriented programming . For a simple example we learn the answer of why… Read More »

Arrays in Kotlin

Two main ways to create array in kotlin. Helper function arrayOf() and constructor Array() .  details of arrayOf() function

to access any element of this array we need to write myArray[index] to get specific value.

It is noted that in array you can assign different data type value . for example

To enforce that all… Read More »

loop in Kotlin

Similar with any other language  loop in kotlin . for loop while loop do while loop basic for loop example

this loop is equivalent of java for loop

note:  in Kotlin if you want to access variable inside double quotation use $ sign to access this variable . While Loop

do while loop 


Conditional Statement in Kotlin (if, when)

at first write a simple program then discuss

this program we read input from user in command line and convert it in Integer . In kotlin readLine() function is used to get input from command line . If else condition in Kotlin is same in any other language . inside if block condition true then enter if block… Read More »

Type Conversion in Kotlin

Here I write 2  line of code . Both are number but the first number is non fractional number. In kotlin non fraction number built in type is Integer . but you wonder why its not byte , short , long . this example second line is a fractional number its default data type is double as… Read More »

Important Notes about basic concent of Kotlin

#Basics You do not need ; to break statements. Comments are similar to Java or C#, /* This is comment */ for multi line comments and // for single line comment. Unlike Java, you do not need to match your file name to your class name. Like JavaScript, you can create functions outside classes. So there is no… Read More »