Syntax

Kotlin Val and Var Syntax

In Kotlin, val and var: val is read-only, var can change — val name = "Ada" var count = 0

Quick Answer

Syntax
val name = "Ada" var count = 0
KotlinSyntax

Val and Var

Code example
val name = "Ada" var count = 0

val is read-only, var can change.

Learn More

How to val and var in Kotlin

  1. Open your Kotlin file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Kotlin Val and Var Syntax

Use val name = "Ada" var count = 0.

Related Syntax References

Frequently asked questions

What is the Kotlin syntax for val and var?

Use this pattern: val name = "Ada" var count = 0

Can I copy this Kotlin code example?

Yes. Use Copy code and adapt the example to your program.

Is this Kotlin syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify