

Import Ĭlass MainActivity : AppCompatActivity(), View. PID: 10600 SIG: 9ĭisconnected from the target VM, address: 'localhost:58784', transport: 'socket' Kotlin.UninitializedPropertyAccessException: lateinit property etT0 has not been initializedĪt .getEtT0(MainActivity.kt:18)Īt .onClick(MainActivity.kt:44)Īt (View.java:7125)Īt (View.java:7102)Īt $3500(View.java:801)Īt $n(View.java:27336)Īt android.os.Handler.handleCallback(Handler.java:883)Īt android.os.Handler.dispatchMessage(Handler.java:100)Īt android.os.Looper.loop(Looper.java:214)Īt (ActivityThread.java:7356)Īt .invoke(Native Method)Īt .RuntimeInit$n(RuntimeInit.java:492)Īt .ZygoteInit.main(ZygoteInit.java:930) my program crashes trying to calculate the average speed in kotlin and i have no idea why it is giving this error and how to fix it. Kotlin keywords have been categorised into three broad categories: (a) Hard Keywords (b) Soft Keywords (c) Modifier KeywordsĪs a good programming practice, it is highly recommended not to use any of the mentioned keywords to name any identifiers while coding in Kotlin.I'm learning kotlin and i'm trying to make a program that calculates the average speed. 3 printlnMethod will input a line of content to standard output. In the Kotlin 1.3mainMethods may not define any parameters or return values. 2 mainMethods are the entry points to programs. But if you dont define it then put the content in the default package. Main.kt:5:21: error: keyword cannot be used as a reference 1 Kotlin is generally defined in a package. Main.kt:2:7: error: expecting property name or receiver type When you run the above Kotlin program, it will generate the following output:

Kotlin uses two different keywords to declare variables: val.

Var fun = "Zara Ali" // Not allowed, throws an exception This topic serves as a Kotlin crash-course to get you up and running quickly. Kotlin uses fun keyword to define a function, so if we we will try to use it as a variable name then it will be an exception. These words cannot be used as an identifier (variables names, package names, function names etc.) and if used then compiler will raise an exception. Kotlin keywords are predefined, reserved words used in Kotlin programming that have special meanings to the compiler.
