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.
Boolean values
From the course: Programming for Non-Programmers: Android & Kotlin
Boolean values
- [Instructor] So far the variables that we've created have been two different data types, numbers and strings. So now I want to introduce a third data type, now that we're talking about conditional statements. And that data type is called Boolean. And Boolean data types are either true or false, so they can only have two values. To create a Boolean variable, you just simply create a normal variable and set it equal to true or false. I'm going to create a property. So right underneath my class, not inside of a method, I'm going to create a Boolean property called isOn. I'll set that equal to false. So var isOn equals false. What we're going to use this for is a switch. We're going to create a button that when we click it, the text view says On. And when we click it again, it checks to see if the value of isOn is equal to true or false, and if it's true, it changes to false; and if it's false, it changes back to true. And that is also going to update the label. So basically, when you…
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
-
-
-
-
-
-
Conditional statements3m 20s
-
(Locked)
Using conditional statements5m 11s
-
(Locked)
Boolean values6m 24s
-
(Locked)
Arrays1m 45s
-
(Locked)
Using arrays3m 4s
-
(Locked)
Loops3m 42s
-
(Locked)
Using loops4m 25s
-
(Locked)
When statements2m 29s
-
(Locked)
Using when statements8m 6s
-
(Locked)
Practical examples of conditional statements2m 35s
-
(Locked)
Challenge: Build a mini calculator app2m 19s
-
(Locked)
Solution: Build a mini calculator app3m 3s
-
-
-
-