1
00:00:01,170 --> 00:00:06,750
Welcome back in this video, we are going to get started with coddling cold, and the focus of this

2
00:00:06,750 --> 00:00:12,960
video will be to, first of all, set up Android Studio so that we can use it in order to learn the

3
00:00:12,960 --> 00:00:14,220
basics very easily.

4
00:00:14,520 --> 00:00:17,910
And then we're going to learn the difference between Vol and VR.

5
00:00:18,270 --> 00:00:24,420
These are super important keywords in Scotland development, and they are really the absolute basis

6
00:00:24,420 --> 00:00:31,350
because you need to have a way to store information for a runtime of your application.

7
00:00:31,650 --> 00:00:35,820
And in this case, we're storing, for example, the amount that something was clicked.

8
00:00:36,030 --> 00:00:39,150
So we're storing it in this variable called times clicked.

9
00:00:39,840 --> 00:00:45,930
But let's go ahead and create a separate project where we are going to not to have all of this boilerplate

10
00:00:45,930 --> 00:00:46,320
code.

11
00:00:46,410 --> 00:00:52,410
So the code, it just is created for us in order to get it even something running, let's really have

12
00:00:52,410 --> 00:00:56,430
a very simplified version of it in Android Studio.

13
00:00:57,000 --> 00:01:01,830
Therefore, let's go ahead and create a new project, and I'm going to create one with no activity.

14
00:01:03,050 --> 00:01:11,060
And I'm going to call this one Scotland basics, Caitlin basics like so you can call it however you

15
00:01:11,060 --> 00:01:16,550
want, and the package name is also not going to be very important in this case because we're not going

16
00:01:16,550 --> 00:01:17,990
to publish this application.

17
00:01:18,200 --> 00:01:20,330
It's really just for us to play around with calling.

18
00:01:20,690 --> 00:01:25,280
The only thing that is important is that you selected Scotland here, which should be done by default.

19
00:01:25,700 --> 00:01:27,650
And now let's create the project.

20
00:01:28,160 --> 00:01:33,800
Now what will potentially happen is that this green stays open, and you don't even know that there

21
00:01:33,800 --> 00:01:39,830
is a second screen open with the Scotland Basic, so you will find that there are two instances of Android

22
00:01:39,830 --> 00:01:40,340
Studio.

23
00:01:40,910 --> 00:01:45,260
OK, so let's go ahead and go into the app folder and then into Java.

24
00:01:45,320 --> 00:01:48,200
And what's important here is that you have Android selected here at the top.

25
00:01:48,200 --> 00:01:50,390
Otherwise the structure will look differently.

26
00:01:50,390 --> 00:01:51,020
As you see here.

27
00:01:51,020 --> 00:01:54,860
If I select Project, for example, of packages, everything looks very different.

28
00:01:55,040 --> 00:02:02,930
So let's go to Android and then on there Java, let's go under you tutorials, Kotlin basics, or however

29
00:02:02,990 --> 00:02:08,600
your package name was that you have selected, and let's create a new Kotlin class slash file.

30
00:02:08,900 --> 00:02:14,300
I'm just going to create a file, not a class and nothing else, just a file that I'm going to call

31
00:02:14,300 --> 00:02:14,840
basics.

32
00:02:15,500 --> 00:02:15,900
OK.

33
00:02:15,920 --> 00:02:20,090
So this creates this basic fact file for me, which is a cotton file.

34
00:02:20,120 --> 00:02:23,360
The extension KP stands for called then and now.

35
00:02:23,360 --> 00:02:28,340
Inside of it, you can see that it just has one line of code and that says Package you tutorials dot

36
00:02:28,340 --> 00:02:29,180
cotton basics.

37
00:02:29,450 --> 00:02:32,150
If it has any more code in here, you can just delete it.

38
00:02:32,390 --> 00:02:35,660
What's important is that it is just a Kotlin file.

39
00:02:36,380 --> 00:02:41,870
OK, now at this point, we can shut down this project part and we can get started with the code.

40
00:02:42,260 --> 00:02:49,340
So I'm going to start with the main function, so I'm using fun- main and then brackets and then curly

41
00:02:49,340 --> 00:02:49,760
brackets.

42
00:02:50,360 --> 00:02:52,660
So this one just ends for function.

43
00:02:52,670 --> 00:02:57,710
So we are creating a function, and this function is called main, which is a very special function.

44
00:02:57,720 --> 00:03:03,170
It's not the general function, it's really a function that is the starting point of our application.

45
00:03:03,470 --> 00:03:06,920
So if I were to create another function here, let's call it.

46
00:03:07,130 --> 00:03:07,640
Hello.

47
00:03:08,540 --> 00:03:11,090
You see that it has a different color.

48
00:03:11,210 --> 00:03:12,320
That's because it doesn't use.

49
00:03:12,620 --> 00:03:15,260
And second of all, I don't have this play button next to it.

50
00:03:15,830 --> 00:03:21,890
So this play button is only going to be available for the main function because, as I said, it's the

51
00:03:21,890 --> 00:03:24,770
entry or starting point for our application.

52
00:03:25,160 --> 00:03:26,930
It doesn't exist for this Hello keyboard.

53
00:03:28,330 --> 00:03:34,780
Now, inside of those brackets, I could add parameters, we're going to see what this means later on.

54
00:03:34,810 --> 00:03:35,830
For now, it doesn't matter.

55
00:03:36,250 --> 00:03:41,830
And then we have the curly brackets and they are important because they are the body of the function.

56
00:03:42,130 --> 00:03:44,410
So what's inside of those curly brackets?

57
00:03:44,440 --> 00:03:49,990
That's the body of the function, and that's where we can add the code that we want to be executed once

58
00:03:49,990 --> 00:03:51,550
we run the code.

59
00:03:51,910 --> 00:03:56,290
So if I run this now, nothing will happen because there's no code inside of the curly brackets.

60
00:03:56,770 --> 00:04:02,530
So even though the Gradle build will run, there's really not anything to be displayed.

61
00:04:02,540 --> 00:04:05,020
So you can see here no text, no nothing.

62
00:04:05,530 --> 00:04:09,550
Let's change that by quickly adding a print statement.

63
00:04:09,700 --> 00:04:14,920
So print is a very special method, and we can now enter something that it should say.

64
00:04:15,040 --> 00:04:17,589
So I'm just going to say print, hello world.

65
00:04:18,220 --> 00:04:19,990
So if I run this code again?

66
00:04:21,220 --> 00:04:22,960
It will display Helloworld here.

67
00:04:23,080 --> 00:04:31,750
You can see now it says Helloworld, this print method is just a code block that tells our I.D.

68
00:04:32,550 --> 00:04:37,660
OK, I want to display something so it displays it onto the console, which is this part here at the

69
00:04:37,660 --> 00:04:38,110
bottom.

70
00:04:38,470 --> 00:04:44,770
So you see run, you can close this by either clicking on the run here or by clicking this hide button.

71
00:04:45,100 --> 00:04:49,060
But then you can open it again by clicking on this run option here at the bottom.

72
00:04:49,420 --> 00:04:52,480
And then you can, of course, make changes to your code.

73
00:04:52,480 --> 00:04:54,710
So let's change it to, for example, Hello Dennis.

74
00:04:55,000 --> 00:04:55,930
And run it again.

75
00:04:57,220 --> 00:04:58,120
And there you are.

76
00:04:58,150 --> 00:05:02,560
You see it says, hello, Dennis, now in our console, which is this part here at the bottom.

77
00:05:03,430 --> 00:05:07,240
OK, so that's the print statement, and we're going to use print statements quite often because they

78
00:05:07,240 --> 00:05:10,360
just allow us to see the value of something.

79
00:05:10,660 --> 00:05:12,820
In this case, to something will be a variable.

80
00:05:13,270 --> 00:05:18,880
So I'm just going to go ahead and create a variable and I'm going to give it the name, my name.

81
00:05:18,890 --> 00:05:21,310
So the variable is going to be called my name.

82
00:05:22,380 --> 00:05:25,560
And then I'm assigning Dennis to it.

83
00:05:26,400 --> 00:05:26,850
All right.

84
00:05:27,450 --> 00:05:31,290
So let's use my name instead of using Dennis here.

85
00:05:31,980 --> 00:05:40,110
So instead of saying Dennis, I'm just going to say hello, empty space plus and then my name, by the

86
00:05:40,110 --> 00:05:43,680
way, you can also see that we are using parentheses here.

87
00:05:44,010 --> 00:05:46,770
So these parentheses that just say that this is a string.

88
00:05:47,310 --> 00:05:53,130
OK, we're going to learn about the data types in the next couple of videos, but for now, we're just

89
00:05:53,130 --> 00:05:54,510
focusing on variables.

90
00:05:55,590 --> 00:05:59,040
So we see that we have this new variable called my name.

91
00:05:59,310 --> 00:06:02,250
And then inside of it, we stored value.

92
00:06:02,280 --> 00:06:05,610
So we assign with this equals sign, we store the value Dennis.

93
00:06:07,970 --> 00:06:13,770
This allows us then to re-use this variable and use it in our print statement.

94
00:06:13,820 --> 00:06:20,390
So what we're doing here is we're just saying hello and this space and then at the point after that,

95
00:06:20,390 --> 00:06:23,240
we add the entry of my name.

96
00:06:24,530 --> 00:06:29,090
OK, so let's run this and see what's going to happen, and you will see that there will be no change.

97
00:06:29,090 --> 00:06:30,440
It will still say hello, Dennis.

98
00:06:31,010 --> 00:06:33,230
So now that's changed it to, for example, Frank.

99
00:06:33,890 --> 00:06:35,450
So my name is going to be frank.

100
00:06:35,480 --> 00:06:36,380
Now, let's change it.

101
00:06:36,770 --> 00:06:38,900
And here to bottom it will say Hello, Frank.

102
00:06:39,860 --> 00:06:44,390
Now there is another thing that we can do with variable, and that is to assign a different value to

103
00:06:44,390 --> 00:06:48,740
it so I can now go ahead and use my name and assign a new value to it.

104
00:06:49,550 --> 00:06:53,210
So I could just say, instead of frank, it should say Heidi.

105
00:06:53,780 --> 00:06:54,200
All right.

106
00:06:54,590 --> 00:06:59,480
So now my name is not going to be frank, but my name is going to be Heidi at that point, because even

107
00:06:59,480 --> 00:07:03,990
though it was assigned Frank at the beginning, it was overwritten later on.

108
00:07:04,010 --> 00:07:09,080
And then when it was actually retrieved or used, it had the value of Heidi.

109
00:07:09,710 --> 00:07:14,390
So let's run our project again, and we will see that now it says Hello, Heidi.

110
00:07:15,680 --> 00:07:22,040
So that is pretty much what you can do with variables, you can store values in them and we're going

111
00:07:22,040 --> 00:07:26,840
to see what kind of values you can store in them because currently we're just storing text in them,

112
00:07:26,840 --> 00:07:27,130
right?

113
00:07:27,230 --> 00:07:29,120
In this particular case, even names.

114
00:07:29,480 --> 00:07:32,330
But of course, you could store other types of text in them as well.

115
00:07:33,320 --> 00:07:41,660
And now we have used another keyword in the last video, which was vault, so we didn't use VAR, but

116
00:07:41,660 --> 00:07:42,680
instead we used it.

117
00:07:43,130 --> 00:07:49,310
Now the difference between VAR and Vault is that a VAR variable can be overwritten.

118
00:07:49,880 --> 00:07:53,920
A VAR variable can not be overwritten, can only be set once.

119
00:07:53,960 --> 00:07:59,630
So here we are, setting the value for that variable and it cannot be overwritten, which is why we

120
00:07:59,630 --> 00:08:00,560
get an error here.

121
00:08:00,830 --> 00:08:02,250
You see, we get a little problem.

122
00:08:02,270 --> 00:08:09,410
We can hover over it and it will say a vault cannot be reassigned, so we cannot assign a new value

123
00:08:09,650 --> 00:08:14,960
to a variable that is using the vault key word when it is created.

124
00:08:16,100 --> 00:08:18,170
So that means that this line is not going to work.

125
00:08:18,710 --> 00:08:24,980
Now we can get rid of it and then everything will be fine, but now we have the name of my name.

126
00:08:25,160 --> 00:08:31,580
So we are writing a variable where we want to only be able to assign it once we don't want our code

127
00:08:31,580 --> 00:08:34,309
at any point to be able to overwrite that value.

128
00:08:34,880 --> 00:08:38,720
And that is what you would use to value keyword for.

129
00:08:40,840 --> 00:08:44,740
And by the way, it's also more efficient in terms of processing power.

130
00:08:44,980 --> 00:08:52,960
So if you know that you don't want to ever override value for a given variable that you are creating,

131
00:08:53,260 --> 00:08:58,960
then use the keyword if you're not sure and you believe that you will have to override it at one point.

132
00:08:59,290 --> 00:09:00,900
Then you use VAR.

133
00:09:01,330 --> 00:09:03,430
Of course, you can start with volume.

134
00:09:03,580 --> 00:09:09,730
And then when you realize I actually want to override the value or reassign a new value to this variable,

135
00:09:09,970 --> 00:09:14,500
then you can change the declaration later on and change that to VAR.

136
00:09:14,770 --> 00:09:20,800
And you can go ahead and just say, change the name here to Claudia, for example.

137
00:09:22,360 --> 00:09:25,530
And let's run it real quick, and we'll see if we get.

138
00:09:25,820 --> 00:09:26,530
Hello, Claudia.

139
00:09:27,160 --> 00:09:30,460
OK, so that's basically the difference between VAR and Vault.

140
00:09:30,460 --> 00:09:33,460
In the next video, we're going to look at the data types of numbers.

