Coding Friction


Kotlin for Loop

It is used to iterate a part of code several times. it iterate through array, collection(like list, map), ranges, String. If body of for loop have only single statement we don’t need to use  curly braces {}. Syntax iterate through range using for loop : in is the operator to check the value in the …

Kotlin for Loop Read More »

Kotlin when Expression

when is the replacement of the switch operator of java. Block of code will executed when some condition is satisfied, also when expression can returns value using braces we can use multiple statements. it can also be used as a statement without any other branch. Let’s take an example. Example 1: Example 2: Combine multiple …

Kotlin when Expression Read More »

Kotlin Control Flow

Kotlin Control Flow Statements It is used to control the flow of program structure, following types of expression in kotlin. if Expression : if the condition of if block is true than if block executes. Syntax: if-else Expression : if condition of If block is true than if block will be executed otherwise else block …

Kotlin Control Flow Read More »

Kotlin Operator

Operators are symbols that perform mathematical or logical operations. It used to perform operations on values and variables. Types of Operators in Kotlin 1. Arithmetic Operators – This operators are used to perform mathematical operations. Operators Meaning Expression Translate to + Addition x + y x .plus(y) – Subtraction x – y x.minus(y) * Multiplication x …

Kotlin Operator Read More »

Kotlin Input Output

Kotlin input output operations performed to flow sequence of bytes or byte streams from input device like keyboard to main memory  and from the main memory to output device like Monitor. Kotlin Output – You can use the following function to display output of any datatype  on the screen.  print() function – it is used …

Kotlin Input Output Read More »

Kotlin Comments

Comments are ignored by the kotlin compiler. comment is a programmer readable explanation about source code that makes source code easier to understand by programmers. Single-line Comments : Kotlin comments starts with two forward slashes // and end with end of the line Multi-line comments : start with /* and ends with */.

Kotlin Type Conversion

it’s also called Type casting , Type Conversion is to convert one data type variable into another data type kotlin doesn’t support implicit type conversion (small to large data type). java supports In java we can assign integer values to long data types but in kotlin isn’t possible.   In kotlin we can’t assign integer value to …

Kotlin Type Conversion Read More »

Kotlin Data Types

It specifies the type of data variable can store like data could be string, integer, numeric, boolean, float. In kotlin all data types behave as object in java need to use wrappers classes(like java.lang.Integer) to behave like objects. you can call member function and properties on any variable. Data types in Kotlin: 1.Integer Data Type …

Kotlin Data Types Read More »

kotlin var vs val

var – Variable delcare with var keywordare are Mutable Variables, value of variable can be changed val – Variable declare with val keyword are Immutable Variables, this is read only variables. it’s not constant value. It is similar to final variable in Java.

Kotlin Variable

Variable is Container to store values, every variable should be declared before using otherwise it gives syntax errors. variable name should be declared using lowerCamelCase In Kotlin to declare variables use var or val keyword and assign a value with (=) equal operator. var – Variable declare with var keyword value can be changed later val …

Kotlin Variable Read More »