Concise

One of Java's biggest issue is verbosity. Anyone who has ever tried writing a simple hello world program in Java will tell you the number of lines of code that requires. Unlike Java, Kotlin is not a verbose language. Kotlin eliminates a lot boilerplate code such as getters and setters. For example, let's compare a POJO in Java to the same POJO in Kotlin.

Student POJO in Java:

public class Student {

private String name;

private String id;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}
}

Student POJO in Kotlin:

class Student() {
var name:String
var id:String
}

As you can see, there's way less Kotlin code for the same functionality.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset