KtDevLog
  • Home
  • Kotlin Fundamentals
  • App Projects
  • Android Studio
  • Firebase
No Result
View All Result
KtDevLog
  • Home
  • Kotlin Fundamentals
  • App Projects
  • Android Studio
  • Firebase
No Result
View All Result
KtDevLog
No Result
View All Result
Kotlin Variables val vs var

Kotlin Variables val vs var

Md Sharif Mia by Md Sharif Mia
April 10, 2026
in Kotlin Fundamentals
Reading Time: 5 mins read
0
0
Share on FacebookShare on Twitter

Val

val name = "Sharif"

Use val for a variable whose value never changes. You can’t reassign a value to a variable that was declared using val. To make it clear: Imagine your name is ‘Sharif’ and you used val. If you later decide to use your nickname ‘Mia’, you can’t , if you try to change a val, your code won’t actually run at all—the computer will give you an error before it even starts. It’s like a locked door; you can’t even try to put a new name in. Example :-

Var

var age = 25

The var keyword means that you can reassign values to age as needed. For example, you can change the value of age from 25 to 26. Example :-

How to visualize val vs var

Think of it like this:

Related Posts

Kotlin Control Flow: If, Else, and When expressions.

Kotlin Control Flow: If, Else, and When expressions.

April 10, 2026
kotlin Data Types

kotlin Data Types

April 10, 2026
Hello World with Kotlin

How to Write a Kotlin Hello World (A Beginner’s Guide)

April 11, 2026
  • val (Value): Is like writing in Stone. Once it’s carved, you can’t change it.
  • var (Variable): Is like writing on a Whiteboard. You can erase “Sharif” and write “Mia” whenever you want.
ShareTweetPin
Md Sharif Mia

Md Sharif Mia

Related Posts

Kotlin Control Flow: If, Else, and When expressions.
Kotlin Fundamentals

Kotlin Control Flow: If, Else, and When expressions.

April 10, 2026

If, Else statement Kotlinval age = 20 if (age >= 18) { println("Welcome to...

kotlin Data Types
Kotlin Fundamentals

kotlin Data Types

April 10, 2026

Numbers Kotlin provides several built-in types to represent numbers, categorized into integers and floating-point...

Hello World with Kotlin
Kotlin Fundamentals

How to Write a Kotlin Hello World (A Beginner’s Guide)

April 11, 2026

Have you ever stared at a blank computer screen, wishing you knew how to...

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • About
  • FAQ
  • Contact
  • Advertise

© 2026 ktdevlog.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
No Result
View All Result
  • Home
  • Kotlin Fundamentals
  • App Projects
  • Android Studio
  • Firebase

© 2026 ktdevlog.