From the course: Programming for Non-Programmers: Android & Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Private properties and constants

Private properties and constants

From the course: Programming for Non-Programmers: Android & Kotlin

Start my 1-month free trial

Private properties and constants

- [Instructor] You may have noticed that some code is highlighted when you're working in Android Studio. Let's talk about why it's highlighted and what issues exist, and how to resolve them. So lines are highlighted when you select them. So if I click on any of these lines of code, just anywhere in here, that line of code becomes highlighted. There are also some other areas of code that stay highlighted regardless. These are warning messages and or suggestions. Watch what happens when I hover over where t says var right here. It says variable is never modified and can be declared immutable using val. So what that's saying is because this variable never changes, we can explicitly say this is a type of variable that never changes. The name for that in code is called a constant. So if I change var to val and click away, you'll see that val is not highlighted like var was because we don't make any changes to this variable's value, and so the warning message goes away. If I try to change…

Contents