Reputation: 81
I have a pojo class in java as below
public class Pojo{
@SerializedName("notificationTime")
private long notificationTime;
public long getNotificationTime(){
return notificationTime;
}
}
Now i am trying this notificationTime in kotlin as below
var notifTime:Long = Pojo.notificationTime
It is showing compiltime error as mentioned . Please help. I am new to kotlin.
Upvotes: 1
Views: 2087
Reputation: 18243
Without an instance, Pojo.notificationTime
tries to call a static method. Which is not what your code exposes.
So init your object, then gets its notificationTime
:
val pojo = Pojo()
val notifTime = pojo.notificationTime // actually calls `getNotificationTime()` as an implicit getter
Upvotes: 2