June 2018
Intermediate to advanced
310 pages
6h 32m
English
Everything is an object in Java. If you have a method that doesn't rely on any state, it still must be wrapped by a class. You're probably familiar with a lot of Util classes in Java that only have static methods, and their only purpose is to satisfy the language requirements and bundle those methods together.
In Kotlin, a function can be declared outside of a class instead of the following code:
public class MyFirstClass {
public static void main(String[] args) { System.out.println("Hello world"); }}
It's enough to have:
fun main(args: Array<String>) { println("Hello, world!")}
Functions declared outside of any class are already static.
Read now
Unlock full access