If there is only one sentence to describe Kotlin, it would be: “Kotlin is great”!
You will not appreciate the beauty of it if you do not suffer from the repetitive, boilerplate coding in java. Let’s see an example first.
Consider you have two classes, as shown below, they do the same thing, interchangeable, exactly the same in terms of functionality, which one do you choose? Left or right one?
The left one is java implementation, and the right, Kotlin.
This is a real example that I encountered in developing an Android App. The App tries to get the new questions on StackOverflow site: Open the link below in your browser to see how you can get the json from StackExchange API:
You will be presented a similar json as below:
In order to display a list of such questions in Android views, I need to deserialize this json string to a POJO (Plain Old Java Object) representation. To avoid hands dirty, we can go to http://pojo.sodhanalibrary.com/ and paste the json string to get the POJO class:
Read the rest of this entry »