1
00:00:00,450 --> 00:00:07,980
Everyone in this Tauriel I'm going to talk about primitive data types and then I'm going to give you

2
00:00:08,220 --> 00:00:14,050
actually some examples about using primitive data types in your Java programs.

3
00:00:14,070 --> 00:00:14,900
OK.

4
00:00:15,180 --> 00:00:18,120
So first we need to create our Java project.

5
00:00:18,330 --> 00:00:23,780
So as you know we just need to click on this find new and then click on Java project.

6
00:00:23,840 --> 00:00:24,450
OK.

7
00:00:24,660 --> 00:00:33,070
And for the project name just type in here primitive primitive data types.

8
00:00:33,900 --> 00:00:34,890
OK.

9
00:00:35,410 --> 00:00:42,040
And for the project's location I choose the default location as you can see here and then click on finish.

10
00:00:42,190 --> 00:00:42,760
OK.

11
00:00:43,000 --> 00:00:45,950
So as you can see here my project is now created.

12
00:00:46,000 --> 00:00:46,740
OK.

13
00:00:46,810 --> 00:00:49,380
Now we need a class for our project.

14
00:00:49,570 --> 00:00:56,590
So just pro-cyclical this is RC folder and the new and then click on class all you can click on this

15
00:00:57,040 --> 00:01:04,630
is our folder or click on these primitive data types project and then click on File Nijo and then click

16
00:01:04,630 --> 00:01:05,290
on class.

17
00:01:05,290 --> 00:01:05,960
OK.

18
00:01:06,220 --> 00:01:14,460
So for the class name just type in here primitive data type data type.

19
00:01:14,580 --> 00:01:15,400
OK.

20
00:01:15,760 --> 00:01:20,440
And for the patch page as I said before you need to do.

21
00:01:20,510 --> 00:01:27,790
Reverse domain name so just type in here or reverse domain name com that Tesa.

22
00:01:28,440 --> 00:01:31,920
And at the end you need to put in the project name.

23
00:01:32,010 --> 00:01:32,860
OK.

24
00:01:33,220 --> 00:01:39,850
Primitive data types are checked.

25
00:01:40,000 --> 00:01:42,790
And for the modifiers choose public.

26
00:01:43,110 --> 00:01:47,980
And here check this checkbox that says public is that it would make me fat.

27
00:01:48,010 --> 00:01:48,830
OK.

28
00:01:49,050 --> 00:01:52,590
This is going to be our starting point for running our coats.

29
00:01:52,600 --> 00:01:54,540
OK this is our main method.

30
00:01:54,750 --> 00:01:56,440
And then click on finish.

31
00:01:57,030 --> 00:02:01,570
So as you can see here our class is created and we are ready to go.

32
00:02:01,590 --> 00:02:02,140
OK.

33
00:02:02,310 --> 00:02:05,990
So first let me actually make this a little area of idea.

34
00:02:06,060 --> 00:02:06,620
OK.

35
00:02:06,750 --> 00:02:09,370
So doubleclick on these primitive data type.

36
00:02:09,370 --> 00:02:10,510
The Java tab.

37
00:02:10,730 --> 00:02:11,350
OK.

38
00:02:11,700 --> 00:02:16,330
So now I'm going to give you some descriptions about primitive data types.

39
00:02:16,350 --> 00:02:19,640
So first I create a multi-line comment here.

40
00:02:19,970 --> 00:02:20,560
OK.

41
00:02:20,850 --> 00:02:26,330
And now I paste subtext here and then I'll let you know what's going on here.

42
00:02:26,340 --> 00:02:27,260
OK.

43
00:02:27,630 --> 00:02:34,740
So primitive data types are actually built in parts of the language which makes them easier to create

44
00:02:34,830 --> 00:02:40,260
and use the first primitive data type that I'm going to explain about is.

45
00:02:40,280 --> 00:02:45,580
But OK so why is an 8 bit integer as you can see here.

46
00:02:45,900 --> 00:02:53,120
And the minimal value that it can hold is this number minus one hundred and twenty eight.

47
00:02:53,430 --> 00:02:58,500
And the maximum value that it can hold is one hundred and twenty seven.

48
00:02:58,600 --> 00:03:03,670
OK the next data type is short as you can see here.

49
00:03:03,960 --> 00:03:06,610
This is 16 bits integer.

50
00:03:06,710 --> 00:03:07,800
OK.

51
00:03:08,190 --> 00:03:15,480
And the minimum value that these data type can hold is this value and the maximum value that this data

52
00:03:15,480 --> 00:03:16,400
type can hold.

53
00:03:16,440 --> 00:03:17,860
Is this OK.

54
00:03:17,940 --> 00:03:22,550
In other words it can hold a value between these two numbers.

55
00:03:22,620 --> 00:03:26,750
The next one is int which you are already familiar with.

56
00:03:26,820 --> 00:03:34,080
This is a first of two bits integer and the minimum value that this state can hold is this value and

57
00:03:34,670 --> 00:03:37,260
the maximum value that this data type can hold.

58
00:03:37,260 --> 00:03:38,420
Is this OK.

59
00:03:38,680 --> 00:03:40,920
It can hold a value between these two numbers.

60
00:03:40,940 --> 00:03:41,490
OK.

61
00:03:42,950 --> 00:03:52,420
And the next one is Lohn this is a 64 bit integer and the minimum value that this data type can hold

62
00:03:52,420 --> 00:03:56,530
is disvalue earn the maximum value that this data type can hold.

63
00:03:56,530 --> 00:03:57,240
Is this ready.

64
00:03:57,250 --> 00:04:00,480
OK if can hold a value between these two numbers.

65
00:04:00,690 --> 00:04:03,870
OK the next primitive data type is float.

66
00:04:03,940 --> 00:04:09,120
As you can see here a lot of data type is a single precision.

67
00:04:09,190 --> 00:04:16,600
First it will be floating point O.J. and the minimum value that this data type can hold is this value

68
00:04:16,690 --> 00:04:17,960
as you can see here.

69
00:04:18,210 --> 00:04:18,740
OK.

70
00:04:18,940 --> 00:04:21,660
And this here means xponent.

71
00:04:21,700 --> 00:04:24,600
OK xponent my minus 45.

72
00:04:24,790 --> 00:04:25,420
OK.

73
00:04:25,660 --> 00:04:31,050
And the maximum value that these days that I can hold is this number OK.

74
00:04:31,140 --> 00:04:40,510
And again this here means exponent and it says exponent 38 OK so floating point numbers are numbers

75
00:04:40,720 --> 00:04:42,600
with a decimal point or J.

76
00:04:42,820 --> 00:04:50,800
And the next primitive data type is double as you can see here double data type is a double precision

77
00:04:51,010 --> 00:04:57,280
64 bits floating point OK and the minimum value that this data type can hold.

78
00:04:57,280 --> 00:05:02,560
Is this number and then the maximum value that the state can hold.

79
00:05:02,560 --> 00:05:04,360
Is this number OK.

80
00:05:04,480 --> 00:05:07,030
And this here means exponent.

81
00:05:07,120 --> 00:05:08,000
OK.

82
00:05:08,350 --> 00:05:12,010
And double data type can be used for more precise numbers.

83
00:05:12,010 --> 00:05:12,520
OK.

84
00:05:12,670 --> 00:05:20,790
So double data type is like flautas data type Ojay and the next one is card or Chad.

85
00:05:20,920 --> 00:05:28,780
I prefer to call it card card data type is a single 16 bit Unicode character and it is used for individual

86
00:05:28,780 --> 00:05:32,680
characters such as letters numbers punctuation and other symbols.

87
00:05:32,710 --> 00:05:33,350
OK.

88
00:05:33,550 --> 00:05:36,700
The next one is Boolean which you are already familiar with.

89
00:05:36,880 --> 00:05:40,150
If can hold either true or false.

90
00:05:40,310 --> 00:05:48,720
OK and we've got constants and other type of variables if the value should never change during our programs

91
00:05:48,720 --> 00:05:57,990
run time Jake you can use a type of variable called a constant A-J and to declare a constant use the

92
00:05:57,990 --> 00:06:05,880
final keyboard before the variable declaration and include an initial value for that variable.

93
00:06:06,060 --> 00:06:06,740
OK.

94
00:06:08,480 --> 00:06:11,860
So now I'm going to give you some real examples to make.

95
00:06:11,860 --> 00:06:13,860
These are primitive data types.

96
00:06:13,970 --> 00:06:15,130
More clear for you.

97
00:06:15,230 --> 00:06:16,170
OK.

98
00:06:16,250 --> 00:06:20,960
Now as you can see here the first primitive data type is byte.

99
00:06:20,990 --> 00:06:21,620
OK.

100
00:06:21,620 --> 00:06:26,060
So first I wanted to type in here byte as are data type.

101
00:06:26,310 --> 00:06:26,890
OK.

102
00:06:27,050 --> 00:06:32,340
This is our data type and we need to give it a name number value.

103
00:06:32,450 --> 00:06:34,560
OK this is our area name.

104
00:06:35,010 --> 00:06:38,710
And as you can see I assigned the value 20 to my variable.

105
00:06:38,990 --> 00:06:42,880
So now I'm going to output this value to the console.

106
00:06:43,010 --> 00:06:43,620
OK.

107
00:06:43,730 --> 00:06:48,250
System that out that print land and then inside Apprentice's.

108
00:06:48,290 --> 00:06:54,770
I just need to put in the name of the variable OK number value and then at the end I just need to put

109
00:06:54,770 --> 00:06:55,970
in the semicolon.

110
00:06:56,240 --> 00:06:59,810
Now as you can see the data type of my variable is fine.

111
00:06:59,930 --> 00:07:07,220
So now I want to assign the value 200 to my body but is now showing an error type mismatch cannot convert

112
00:07:07,460 --> 00:07:08,950
from int to whites.

113
00:07:08,960 --> 00:07:09,490
OK.

114
00:07:09,710 --> 00:07:15,710
So as I said earlier in this tutorial the minimum value that this can hold is minus one hundred twenty

115
00:07:15,710 --> 00:07:18,700
eight and the maximum is 127.

116
00:07:18,790 --> 00:07:19,360
OK.

117
00:07:19,550 --> 00:07:24,980
So despite the I cannot hold a value greater than 127.

118
00:07:25,050 --> 00:07:27,970
OK so I changed this one you to 20.

119
00:07:28,220 --> 00:07:34,820
And if I ran my project now as you can see it now outputs the value of this variable to the console.

120
00:07:34,880 --> 00:07:35,550
OK.

121
00:07:38,380 --> 00:07:41,210
The next primitive data type is short.

122
00:07:41,240 --> 00:07:44,080
Ok so first we need to type in the data type.

123
00:07:44,080 --> 00:07:50,160
Short as you can see here and I'm going to actually give this variable a name will you.

124
00:07:50,380 --> 00:07:51,070
OK.

125
00:07:51,250 --> 00:07:54,530
And then I assign a value to this variable.

126
00:07:54,850 --> 00:07:55,590
OK.

127
00:07:55,840 --> 00:07:57,250
As you can see here.

128
00:07:57,670 --> 00:08:04,510
So now I want to actually output the value of this variable to the console system that out that printin

129
00:08:04,960 --> 00:08:09,480
and then inside Apprentice's I just need to put in the name of the variable.

130
00:08:09,490 --> 00:08:10,560
Ok are you.

131
00:08:10,750 --> 00:08:11,360
OK.

132
00:08:11,530 --> 00:08:14,860
And then at the end I need to put in the semi-colon.

133
00:08:15,160 --> 00:08:21,030
And as you can see here first I want to actually comment out this line of code here.

134
00:08:21,070 --> 00:08:28,190
And if I run my project now it's going to outputs the value of these Baali invaluable to the Carson.

135
00:08:28,210 --> 00:08:32,220
Now I want to assign a very large value to this variable.

136
00:08:32,410 --> 00:08:35,330
So as you can see here it's now showing you an error.

137
00:08:35,350 --> 00:08:35,920
OK.

138
00:08:36,160 --> 00:08:39,230
So it says cannot convert from Int.

139
00:08:39,260 --> 00:08:39,930
OK.

140
00:08:40,180 --> 00:08:46,080
As I said earlier a distorted data I can only hold a value between these two numbers.

141
00:08:46,090 --> 00:08:46,710
OK.

142
00:08:46,990 --> 00:08:49,600
So it cannot hold these very large value.

143
00:08:49,600 --> 00:08:50,250
OK.

144
00:08:50,650 --> 00:08:52,980
So I need to change this value.

145
00:08:53,260 --> 00:09:01,120
The next primitive data type is it which you are already familiar with the name of the variable is score.

146
00:09:01,280 --> 00:09:07,060
And I can actually assign a value to these very OK.

147
00:09:07,180 --> 00:09:10,140
And then at the end I just need to put in a semi-colon.

148
00:09:10,270 --> 00:09:15,280
And here I want to actually output the value of this variable to the console.

149
00:09:15,310 --> 00:09:19,820
So a system that out that print line and then inside the parenthesis.

150
00:09:19,960 --> 00:09:22,180
I just need to refer to the name of the variable.

151
00:09:22,180 --> 00:09:22,940
OK.

152
00:09:23,470 --> 00:09:27,500
And now let me actually comment out this line of code here.

153
00:09:27,730 --> 00:09:32,770
And then if I run my project now as you can see it's going to output the value of this variable to the

154
00:09:32,770 --> 00:09:33,230
console.

155
00:09:33,250 --> 00:09:34,110
OK.

156
00:09:34,540 --> 00:09:39,770
So here I want to actually again assign a very large value to like to my variable.

157
00:09:40,000 --> 00:09:43,500
So as you can see it says this value is out of range.

158
00:09:43,510 --> 00:09:44,390
OK.

159
00:09:44,530 --> 00:09:51,860
So as I said earlier at the state it can only hold a value between these two numbers.

160
00:09:51,880 --> 00:09:52,590
OK.

161
00:09:52,690 --> 00:09:59,380
We cannot actually assign a value greater than the maximum value that this data type can hold.

162
00:09:59,410 --> 00:10:00,070
OK.

