‫Hello, my friends, and welcome back.
‫In this video, let's explore the various number data types in Java.
‫So we'll take an example about byte short, long and end.
‫Let's start with the byte here.
‫The byte is a data type that it's used to store whole numbers from -128 to 127.
‫It's an eight bit.
‫Integer.
‫In order to create a bite.
‫We start with bite keyword with small letter, and here we specify the name of the bite variable.
‫Let's name it as x equal to and give it a value 100 like this.
‫This is how we create a byte variable in Java.
‫Some may ask why this range.
‫So I can't put like 130, for example.
‫130.
‫Like this.
‫No, there is an error here.
‫This red line telling us if we click on this red bulb, we can see that required type is byte provided
‫is an int.
‫So we need to provide an int transform this x variable from byte to int in order to store this value,
‫which is 130, which is outside of this byte range.
‫So please pay attention to your range, your numbers and your expected values of your numbers.
‫So for that we have a wide variety of numbers in Java.
‫So the maximum number that can access store is one, two, 7 or 1 minus one two eight.
‫Now let's move to the second data type, which is the short.
‫The short data type is a 16 bit that can store whole numbers from -32,768 to 32,767.
‫Now to create short, we start with the short keyword and I'll name this short as Y and I'll give it
‫a value.
‫Seven, seven, seven, seven.
‫You can see that it's created with no errors because 7777 is included inside this range.
‫If I add two more numbers, two more sevens I can get, or this Android studio will give me an error
‫because as I am providing an end value to a short, either I need to change it to an end.
‫You can see the problem is solved or I need to remove or reduce the number to be included inside the
‫range.
‫The third type of primitive data types and the third type in numbers is the end.
‫The end data type is a 32 bit integer.
‫It can store whole numbers from this number minus this number two plus this number.
‫It's the most commonly used data type for the whole numbers in Java.
‫In order to create an integer, we start with int keyword and I'll name it as z equal to eight, eight,
‫seven, seven, six, six, five, five, and so on.
‫Don't miss the semicolon.
‫The fourth type of numbers is the lung.
‫The lung data type is a 64 bit integer.
‫It can store very large whole numbers from minus this number to plus this number.
‫To define a lung value, you should add capital L or small L at the end of the number.
‫So for that I start with the lung keyword in Java and I'll name it as W equal and I'll give it a value.
‫For example, 1122334455, six, six, seven, seven, eight, eight.
‫And here I have an error integer number too large because this ID or Android studio will understand
‫that this is an integer in order to tell Android stated that this number is not integer.
‫It's an it's a lung.
‫I need to add capital L at the end of this value.
‫Or a small L.
‫Okay.
‫But I prefer adding capital L because it's more readable.
‫So this is how we define the Lang in Java.
‫This is how we define integers, short and byte.
‫These are the numbers in Java.