Everyone in this Tauriel I'm going to talk about primitive data types and then I'm going to give you
actually some examples about using primitive data types in your Java programs.
OK.
So first we need to create our Java project.
So as you know we just need to click on this find new and then click on Java project.
OK.
And for the project name just type in here primitive primitive data types.
OK.
And for the project's location I choose the default location as you can see here and then click on finish.
OK.
So as you can see here my project is now created.
OK.
Now we need a class for our project.
So just pro-cyclical this is RC folder and the new and then click on class all you can click on this
is our folder or click on these primitive data types project and then click on File Nijo and then click
on class.
OK.
So for the class name just type in here primitive data type data type.
OK.
And for the patch page as I said before you need to do.
Reverse domain name so just type in here or reverse domain name com that Tesa.
And at the end you need to put in the project name.
OK.
Primitive data types are checked.
And for the modifiers choose public.
And here check this checkbox that says public is that it would make me fat.
OK.
This is going to be our starting point for running our coats.
OK this is our main method.
And then click on finish.
So as you can see here our class is created and we are ready to go.
OK.
So first let me actually make this a little area of idea.
OK.
So doubleclick on these primitive data type.
The Java tab.
OK.
So now I'm going to give you some descriptions about primitive data types.
So first I create a multi-line comment here.
OK.
And now I paste subtext here and then I'll let you know what's going on here.
OK.
So primitive data types are actually built in parts of the language which makes them easier to create
and use the first primitive data type that I'm going to explain about is.
But OK so why is an 8 bit integer as you can see here.
And the minimal value that it can hold is this number minus one hundred and twenty eight.
And the maximum value that it can hold is one hundred and twenty seven.
OK the next data type is short as you can see here.
This is 16 bits integer.
OK.
And the minimum value that these data type can hold is this value and the maximum value that this data
type can hold.
Is this OK.
In other words it can hold a value between these two numbers.
The next one is int which you are already familiar with.
This is a first of two bits integer and the minimum value that this state can hold is this value and
the maximum value that this data type can hold.
Is this OK.
It can hold a value between these two numbers.
OK.
And the next one is Lohn this is a 64 bit integer and the minimum value that this data type can hold
is disvalue earn the maximum value that this data type can hold.
Is this ready.
OK if can hold a value between these two numbers.
OK the next primitive data type is float.
As you can see here a lot of data type is a single precision.
First it will be floating point O.J. and the minimum value that this data type can hold is this value
as you can see here.
OK.
And this here means xponent.
OK xponent my minus 45.
OK.
And the maximum value that these days that I can hold is this number OK.
And again this here means exponent and it says exponent 38 OK so floating point numbers are numbers
with a decimal point or J.
And the next primitive data type is double as you can see here double data type is a double precision
64 bits floating point OK and the minimum value that this data type can hold.
Is this number and then the maximum value that the state can hold.
Is this number OK.
And this here means exponent.
OK.
And double data type can be used for more precise numbers.
OK.
So double data type is like flautas data type Ojay and the next one is card or Chad.
I prefer to call it card card data type is a single 16 bit Unicode character and it is used for individual
characters such as letters numbers punctuation and other symbols.
OK.
The next one is Boolean which you are already familiar with.
If can hold either true or false.
OK and we've got constants and other type of variables if the value should never change during our programs
run time Jake you can use a type of variable called a constant A-J and to declare a constant use the
final keyboard before the variable declaration and include an initial value for that variable.
OK.
So now I'm going to give you some real examples to make.
These are primitive data types.
More clear for you.
OK.
Now as you can see here the first primitive data type is byte.
OK.
So first I wanted to type in here byte as are data type.
OK.
This is our data type and we need to give it a name number value.
OK this is our area name.
And as you can see I assigned the value 20 to my variable.
So now I'm going to output this value to the console.
OK.
System that out that print land and then inside Apprentice's.
I just need to put in the name of the variable OK number value and then at the end I just need to put
in the semicolon.
Now as you can see the data type of my variable is fine.
So now I want to assign the value 200 to my body but is now showing an error type mismatch cannot convert
from int to whites.
OK.
So as I said earlier in this tutorial the minimum value that this can hold is minus one hundred twenty
eight and the maximum is 127.
OK.
So despite the I cannot hold a value greater than 127.
OK so I changed this one you to 20.
And if I ran my project now as you can see it now outputs the value of this variable to the console.
OK.
The next primitive data type is short.
Ok so first we need to type in the data type.
Short as you can see here and I'm going to actually give this variable a name will you.
OK.
And then I assign a value to this variable.
OK.
As you can see here.
So now I want to actually output the value of this variable to the console system that out that printin
and then inside Apprentice's I just need to put in the name of the variable.
Ok are you.
OK.
And then at the end I need to put in the semi-colon.
And as you can see here first I want to actually comment out this line of code here.
And if I run my project now it's going to outputs the value of these Baali invaluable to the Carson.
Now I want to assign a very large value to this variable.
So as you can see here it's now showing you an error.
OK.
So it says cannot convert from Int.
OK.
As I said earlier a distorted data I can only hold a value between these two numbers.
OK.
So it cannot hold these very large value.
OK.
So I need to change this value.
The next primitive data type is it which you are already familiar with the name of the variable is score.
And I can actually assign a value to these very OK.
And then at the end I just need to put in a semi-colon.
And here I want to actually output the value of this variable to the console.
So a system that out that print line and then inside the parenthesis.
I just need to refer to the name of the variable.
OK.
And now let me actually comment out this line of code here.
And then if I run my project now as you can see it's going to output the value of this variable to the
console.
OK.
So here I want to actually again assign a very large value to like to my variable.
So as you can see it says this value is out of range.
OK.
So as I said earlier at the state it can only hold a value between these two numbers.
OK.
We cannot actually assign a value greater than the maximum value that this data type can hold.
OK.