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
From the course: Programming for Non-Programmers: Android & Kotlin
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
How programming works3m 58s
-
(Locked)
Variables3m 33s
-
(Locked)
Working with variables5m
-
(Locked)
Using properties2m 53s
-
(Locked)
Connect visual objects to variables6m 39s
-
(Locked)
Enum values5m 30s
-
(Locked)
Private properties and constants4m 53s
-
(Locked)
Practical applications of variables2m 22s
-
(Locked)
Challenge: Create two variables1m 9s
-
(Locked)
Solution: Create two variables2m 41s
-
-
-
-
-
-