Languages

Build-In Support

EnlighterJS v2.12.0 is out including new Languages & Themes. View the Changelog

Kotlin

Select Theme

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor static num = 0; invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.

package com.example

import java.time.LocalDate

data class Person(var firstName: String, var lastName: String, var birthdate: LocalDate) {

    fun getAge(): Int {
        return LocalDate.now().year - birthdate.year;
    }

}

fun main(args: Array<String>) {
    val person1 = Person("Samuel", "Jackson", LocalDate.of(1948, 12, 21));
    val person2 = Person("Quentin", "Tarantino", LocalDate.of(1963, 3, 27))

    val persons = listOf<Person>(person1, person2)

    val personsAbove50 = persons.filter { it.getAge() > 50 }

    println(personsAbove50)

    println("First Name: ${person1.firstName}")

    val jsonString = """[
      {"firstName":"Samuel", "lastName": "Jackson"},
      {"firstName":"Quentin", "lastName": "Tarantino"}
    ]"""

    println(jsonString)
}