Reputation: 206
I am new to kotlin and I want to initialize object from java class in Kotlin class.
I have java class Car for
example com.myapp.vehicles.car
in java I would do
buss = new car()
then call buss.drive()
how do I do same from kotlin.
I have tried var buss = car.getinstance()
but there is no method getinstance
Upvotes: 3
Views: 6881
Reputation: 3976
getInstance()
method created by itself for initialization.
in Java
buss = new car()
call =buss.drive()
In kotlin
var buss = car()
var method = buss.drive()
Upvotes: 6
Reputation: 13565
In kotlin no need to new
world so just type this for new instance of class
var buss = car()
Now you can use all object and function of car
class
Also i suggest use Uppercase for start letter of your classes
Upvotes: 1