Inspired by my enthusiasm for Android technology.
-
object-oriented programming
Kotlin uses classes, which can be instantiated as objects. Classes may have class functions. Kotlin supports subclasses and superclasses. -
file ingestion
Kotlin is derived from Java, and as such, there exists the ability to import java packages. For this project, I imported java.io.File and used its readLines() function. For example:
import java.io.File
fun main() {
val fileName = <filename here>
File(fileName).readLines()
...content here...
}
- conditional statements
Kotlin uses if, if-else, the 'is' operator, and 'when' expressions for conditional statements. For example:
//if and if-else #1
if (x > 5){
<do something> //could stop here or continue with else
} else {
<do something else>
}
//if-else #2
val result = if (x > 5) <do something> else <do something else>
//when
val x = 5
when (x){
5 -> "yay x is 5!"
6 -> "hey, x is not 5!"
else -> "what is x, anyway?"
//is
val obj: Any = "I'm an object"
when(obj){
is String -> "I'm a String object"
is Int -> "I'm an Int object"
else -> "I don't know what type of object I am"
-
assignment statements
Kotlin supports the '=' assignment operator, as well as combination operators. These assignments include addition (+=), subtraction (-=), multiplication (*=), division (/=), and modulus (%=). -
Loops
Kotlin supports for-loops, while-loops, and do-while-loops. -
subprograms (functions/methods)
Subprograms are signalled by the 'fun' keyword. Subprograms can exist as part of a class, or they can exist in their own separate file, as long as they exist within the same package. -
Unit testing and exception handling
Typically, JUnit is imported to perform unit testing. Kotlin is interoperable with Java, which makes this convenient.
Kotlin uses try-catch blocks, and try-catch-finally blocks for exception handling, as well as the keyword 'throw'.
- JUnit for unit testing
- OpenJDK: corretto-17 for runtime environment
- KotlinJavaRuntime: runtime and Java interoperability component



