
These words cannot be used as an identifier (variables names, package names, function names etc.) and if used then compiler will raise an exception. For example, sumOfTwo.Kotlin keywords are predefined, reserved words used in Kotlin programming that have special meanings to the compiler. If you wish to include two words in an identifier than you can start the second word with a capital letter. For example: add, multiply and divide are the meaningful identifier than the a, m and d.Ħ. It is a best practise to give meaningful names to the identifiers. An identifier can start with an underscore “_”.ĥ. They cannot contain special characters such as #, % etc.Ĥ. Identifiers in Kotlin are case sensitive.ģ. The identifier cannot have whitespaces.Ģ. Naming convention of Kotlin Identifiersġ. The name that we give to a variable, class, function etc is known as identifier. There are several other soft keywords available in Kotlin such as catch, get, finally, field etc. We can use the keyword “by” as identifier as well. For example, “by” is a soft keyword which delegates the implementation of an interface to another object. Apart from the above list of keywords, there are other keywords that can be used as identifiers.

Soft keywords are the keywords that are used only in a certain context which means we can use them as identifier. Val else = 5 Kotlin Hard keywords Table as

This is invalid: //error: "else" cannot be used as a variable name These keywords cannot be used as identifiers. In this guide, we will learn about keywords and identifiers. These words are called reserved words or keywords. There are certain words in Kotlin that have special meaning and cannot be used as identifiers(variable name, function name, class name etc).
