Kotlin's data class construct defines classes whose primary purpose is storing data. This construct is similar to normal classes except that the key functions equals, toString, and hashCode are automatically generated from the class properties. In Java, such classes are expected to provide a standard assortment of functions such as those. Data classes are not required to declare any methods, though each must have at least one property. A data class often is written without a body, though it is possible to give a data class any methods or secondary constructors that are valid for any other class. The data keyword is used before the class keyword to define a data class. // data class with parameters and their optional default values data class Book(val name: String = "", val price: Int = 0) fun main(args: Array<String>) { // create a data class object like any other class object var book1 = Book("Kotlin Programming", 250) println(book1) // output: Book(name=Kotlin Programming, price=250) } Kotlin interactive shell $ kotlinc-jvm type :help for help; :quit for quit >>> 2 + 2 4 >>> println("Hello, World!") Hello, World! Kotlin as a scripting language Kotlin can also be used as a scripting language. A script is a Kotlin source file (.kts) with top level executable code. // list_folders.kts import java.io.File val folders = File(args[0]).listFiles { file -> file.isDirectory() } folders?.forEach(::println) Scripts can be run by passing the -script option and the corresponding script file to the compiler. $ kotlinc -script list_folders.kts "path_to_folder_to_inspect" Null safety Kotlin makes a distinction between nullable and non-nullable data types. All nullable objects must be declared with a "?" postfix after the type name. Operations on nullable objects need special care from developers: null-check must be performed before using the value. Kotlin provides null-safe operators to help developers: (safe navigation operator) can be used to safely access a method or property of a possibly null object. If the object is null, the method will not be called and the expression evaluates to null. (null coalescing operator) often referred to as the Elvis operator: fun sayHello(maybe: String?, neverNull: Int) { // use of elvis operator val name: String = maybe ?: "stranger" println("Hello $name") } An example of the use of the safe navigation operator: // returns null if... // - foo() returns null, // - or if foo() is non-null, but bar() returns null, // - or if foo() and bar()