Kotlin Flashcards
modern but already mature programming language designed to make developers happier
kotlin
Kotlin was built by software development tool creators ___ in 2010
JetBrains
Why use ‘Kotlin‘?
- Kotlin is fully compatible with Java
- Kotlin works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
- Kotlin is concise and safe
- Kotlin is easy to learn, especially if you already know Java
- Kotlin is free to use Big community/support
What is the IDE used for Kotlin (in our case)?
IntelliJ
is the entry point for a Kotlin application
Function Declaration
This keyword is short for “function” and is used to declare a function in Kotlin.
fun
This is the name of the function. By convention, it’s called main and serves as the entry point for the program
main
How do we write comments?
/**/ - multiline comments
// - one liner comments
is used to declare a mutable variable, which means its value can be changed or reassigned after it’s initially assigned
var
is used to declare an immutable variable, which means its value cannot be changed or reassigned after it’s initially assigned. It’s essentially a constant.
val
Represents 32-bit signed integers
int
Represents 64-bit signed integer
long
Represents 16-bit signed integers
short
Represents 8-bit signed integers
byte
epresents 32-bit floating-point numbers
float
Represents 64-bit floating-point numbers
double
Represents true or false values
boolean
Represents a single character
char
Represents a sequence of characters
string
2 ways to input in kotlin
1.) val scanner = Scanner(System.in
)
val name = scanner.next()
2.) val name = readLine()
are used to assign values to variables
Assignment operators
are used to compare two values, and returns a Boolean value: either true or false
Comparison operators
are used to determine the logic between variables or values
Logical operators
(also called as Type casting) refers to changing the entity of one data type variable into another data type.
Type conversion
how to type cast?
varname.toString()
varname.toFloat()