Lab 2
Lab 2
Assignment operators
Comparison operators
Logical operators
ARITHMETIC OPERATOR
ASSIGNMENT OPERATOR
COMPARISON OPERATOR
LOGICAL OPERATOR
KOTLIN STRING
A string contains a collection of characters surrounded by
double quotes.
If you want to create a String without assigning the value
(and assign the value later), you must specify the type while
declaring the variable:
KOTLIN STRING
Use [ ] to access the characters in a string by referring to its
index number.
plus() function to concatenate two strings.
KOTLIN STRING
Concatenation (+) used between strings to add them
together to make a new string .
KOTLIN STRING
length function: to get the length of a string.
indexOf() function returns the index (the position) of the first
occurrence of a specified text in a string (including
whitespace)
KOTLIN CONDITIONS
if statement to specify a block of Kotlin code to be executed
if a condition is true.
else if statement to specify a new condition if the first
condition is false.
Instead of writing many if..else expressions, you can use the
when expression.
The when expression is similar to the switch statement in
Java.
you can also create ranges of values with ".."
KOTLIN CONDITIONS
KOTLIN LOOPS
The while loop loops through a block of code as long as a
specified condition is true.
The do..while loop is a variant of the while loop. This loop will
execute the code block once, before checking if the condition is
true, then it will repeat the loop as long as the condition is true.
The break statement is used to jump out of a loop ” means exist
from the current loop”.
The continue statement breaks one iteration (in the loop), if a
specified condition occurs, and continues with the next iteration
in the loop “means leave the current iteration and starts a new
iteration”.
WHAT IS THE OUTPUT?
WHAT IS THE OUTPUT?
THANKS Eng.Marwa
ELDeeb