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
getInstance() method created by itself for initialization.
in Java
buss = new car()
call =buss.drive()
In kotlin
var buss = car()
var method = buss.drive()
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With