Category: Kotlin Tutorial
-
Kotlin Comment
Comments are the statements that are used for documentation purpose. Comments are ignored by compiler so that don’t execute. We can also used it for providing information about the line of code. There are two types of comments in Kotlin. Single line comment Single line comment is used for commenting single line of statement. It…
-
Kotlin Standard Input/Output
Kotlin standard input output operations are performed to flow byte stream from input device (keyboard) to main memory and from main memory to output device (screen). Kotlin Output Kotlin output operation is performed using the standard methods print() and println(). Let’s see an example: Output The methods print() and println() are internally call System.out.print() and System.out.println() respectively. Difference…
-
Kotlin Operator
Operators are special characters which perform operation on operands (values or variable).There are various kind of operators available in Kotlin. Arithmetic Operator Arithmetic operators are used to perform basic mathematical operations such as addition (+), subtraction (-), multiplication (*), division (/) etc. Operator Description Expression Translate to + Addition a+b a.plus(b) – Subtraction a-b a.minus(b) *…
-
Kotlin Type Conversion
Type conversion is a process in which one data type variable is converted into another data type. In Kotlin, implicit conversion of smaller data type into larger data type is not supported (as it supports in java). For example Int cannot be assigned into Long or Double. In Java In Kotlin However in Kotlin, conversion…
-
Kotlin Data Type
Data type (basic type) refers to type and size of data associated with variables and functions. Data type is used for declaration of memory location of variable which determines the features of data. In Kotlin, everything is an object, which means we can call member function and properties on any variable. Kotlin built in data type…
-
Kotlin Variable
Variable refers to a memory location. It is used to store data. The data of variable can be changed and reused depending on condition or on information passed to the program. Variable Declaration Kotlin variable is declared using keyword var and val. The difference between var and val is specified later on this page. Here, variable language is…
-
Kotlin First Program Printing ‘HelloWorld’
Let’s create a Kotlin first example using IntelliJ IDEA IDE. Steps to Create First Example 1. Open IntelliJ IDEA and click on Create New Project’. 2. Select Java option, provide project SDK path and mark check on Kotlin/JVM frameworks. 3. Provide the project details in new frame and click ‘Finish’. 4. Create a new Kotlin file to run Kotlin…
-
Kotlin Environment Setup (IDE)
Install JDK and Setup JDK path Since, Kotlin runs on JVM, it is necessary to install JDK and setup the JDK and JRE path in local system environment variable. Use this link https://www.javatpoint.com/how-to-set-path-in-java to setup JDK path. Install IDE for Kotlin There are various Java IDE available which supports Kotlin project development. We can choose these IDE…
-
Kotlin First Program Concept
Let’s understand the concepts and keywords of Kotlin program ‘Hello World.kt’. 1. The first line of program defines a function called main(). In Kotlin, function is a group of statements that performs a group of tasks. Functions start with a keyword fun followed by function name (main in this case). The main () function takes an array of string (Array<String>) as…
-
Kotlin Hello World Program in Command line.
To write Kotlin program, we can use any text editor like: Notepad++. Put the following code into any text file and save. Save the file with name hello.kt, .kt extension is used for Kotlin file. Compile Kotlin File Open command prompt and go to directory location where file is stored. Compile hello.kt file with following command. Run Kotlin File…