January 2018
Intermediate to advanced
434 pages
14h 1m
English
In Kotlin, decompiling bytecode is always a great way to know what is happening behind the scenes. If we decompile the bytecode of the object we created, we get the following code, which shows that behind the scenes, the object is just a class with a single instance at a time:
public final class SomeClass { @NotNull private static String intro; public static final SomeClass INSTANCE; @NotNull public final String getIntro() { return intro; } public final void setIntro(@NotNull String var1) { Intrinsics.checkParameterIsNotNull(var1, "<set-?>"); intro = var1; } @NotNull public final String infoIntro() { return "I am some class. Pleased to meet you!"; } private SomeClass() { INSTANCE = (SomeClass)this; intro = "I am some class. ...Read now
Unlock full access