Java Step 1: Data types | Irina Galkina | Skillshare

Java Step 1: Data types

Irina Galkina, Easy programming.

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
7 Lessons (19m)
    • 1. Intro.

    • 2. Environment.

    • 3. Variables.

    • 4. Integers: byte and short.

    • 5. Integers: int and long.

    • 6. Floating point types.

    • 7. Character and boolean.


About This Class


This class is about Java basics, about data types.

In this class we will learn:

  • how many primitive types we have in Java;
  • what is variable and how it holds in Java memory;
  • what the difference between integers types and floating point types;
  • how many memory different types take in Java.

Wellcome to this class to make your knowledge in Java clear and consistent!


1. Intro.: Hello, Java lovers. Let's talk about something interesting and simple in Jama, something that plays in the base off each programming about data types. In this class, we will learn how many primitive types for half in Java with the difference between them, how to use them. How old this arrange in job a memory and white. So welcome to this class and make your knowledge, Angela clear and behave. 2. Environment.: hello, Java lovers. Let's talk about basics off job and the very basic off each programming language is, of course, the types in Java. We have two main types of data types, so its object and primitive. So everything's that's not an object is a primitive, and everything that's not a primitive is enough. But Phil sink first, and for this class, you need to don't load adjudicate and village idea. So I put ceilings in the resources off this class. So I just go, Does this links and just download community addition off intelligent idea and go to the Oracle website? Just press job a download Oh, chick, except license and just choose my system and download job, um, applicable for my system. And now I just need to connect my gin decay. And Mindel jt, I just crunched my in college idea. Choose great new project and he will see in the project. Is the Cape list empty place. So here you just need to set up your past to adjudicate. I just click you ju decay and choose the directory ways. Mandela was saved. So after that, you will see here your jam abortion and can create your new project job types 3. Variables.: is this leader is about variables. So what is available? Let's just imagine all memory space that we have for our job program. And let's take a smear, a small piece of memory for our needs just to remember something. Maybe. How many cats have how many books that have, or something like that? After that, we just ask Java, Give us our small piece of memory, and to use it, we should call. It's have how we should give it a name. So the variable is a pissed off memories that can hold someone for with a name and dependent on what we're gonna safe. In this variable, we can choose different date tapes according toa our projects. Let's great. In a sense, it's a folder our fills Java file like main file here. We should great start born for each job problem. Probably public static would main PSV amid an idea and it will create it for you. And here I can create my first variable. So first of all, I should set type into chur. We will discuss intent er in the next videos name let like a and the data like 45. So I just created my felt variable 4. Integers: byte and short.: So in job, we have a tight off primitives. And first of all, let's talk About Indigenous introduces Ifill's type of primitives. It helds. It holds for primitive types. Byte short into integer and and the first type is so bite. So that's great. Variable is a tight, but I just I bite to be equals something like 100 men to seven. So bite is the primitive types that holds memory. One bite, obviously, and it can help values from minus 188 to 127. Let's put in our primitive types like fight the biggest value that it can hold like, for example, but harden 27 and just increase it by one like me plus plus, it increases the very in the beaver variable just at one. So what will happen? Let's just see. I just type this out be It just brings our be the values that we hold on me in our console . Just wrong Maine, of course. And we will see that here. Miners 188. Why so so Java constructed that way that we if we just put the biggest value in the primitive in the variable R and just increased by one will find our meribel on the left side's off. Always, news said it variable can hold. So that is how it works in Java. So now it's time to talk about short. Short is the next interred your primitive. Just that short, like big shoes and ambles is available. 345 civilians that will hold and chart takes, um uh, two bites in memory. 16 beats off course cause one bite. It's eight, it's and it can held banners from miners to raise to the power off 15 to to race to the power or 15. And if ah took literally eat mine industry. 32,700 for 68 and certain 2000 seven hungry 67. So it's all about Charlie and Bite and how they behave in job 5. Integers: int and long.: and this video will talk about the last one to Inter just to interject. Primitives are in and long, so 1st 1 is that think just type wouldn't be free. Could some value So he takes in memory. Four. Bites certain two minutes and you can held values for miners to race to the power off certain bond to to raised to the power off. 31 My noose one. Um, let's do something interesting was in Detroit, so I just created peace free and put the 456 in it. And what will happen if I just put in this inter general as a result Off division for by three, What will happen? That's not an integer. So what will happen? It will be like one or maybe two, or may become zinc and the other one. So let just test it. It's out. Beat three and just right that in consult. And here I can see that I have 11 because in ended years, of course, we can have had hold home the integers and on, and they're floating number. It just cut not selling to the to know Downing toe that one in just cut Even if it will be 1.99999 The offloading part We will be just caught So that how it works in Chow so and now we have only the West. The last one integer long the biggest one, So I just I belong. L here can type some big indigent and it takes memory 40 64 minutes Sorry and 44 and eight bites. And it can hold values from miners to race to the power off 63 does there too, Raised to the power ar minus toe raised to the power of 63 to 2. Great to the power off 60 sweet minus one. Um, that's all about intercourse types and I want to check something here. He I type just to race to the power 15 and off course here should be to erased the power off 15 minus one. And after all the stuff, you maybe should have two questions. First of just one is why we always do minus one. My new swan minus von and one hungry 27 in less by one white, because the primitive type can hold the amount off values. And here is Elsa 00 else. A value ends this primitive can hold it. And as we have on Lee, one bite or maybe two bites. So we can We can just take one more. We should put zero in our piece of memory. So because of zero, we have this minus one. And the second question is no complicated. So why we used here's that part one less than number off beats by So sorry I am, of course, Ah, bits. That's because of the miners. In primitive variables, we hold positive and negative values and for the negative values we should hold this miners and the spine owes holds in one beats. That's why we use Onley one less bits in each primitive. So that's all about integers and our next topic is floating numbers. 6. Floating point types.: the next to that is floating point numbers. Voting poll point numbers is else known. Israel numbers, and we use them when we need to emulate an expression with a fraction precision. Just type float. If the name of variable float it takes memory started to beats for whites and we can use flow to a prison number, said me diffraction. But don't need other precision like currency troopers and dollars, euros or roubles is the next step is double Godbold. Do you? Uh, it takes memory 64. They bites and we use double when we need develop some expression with more precision, like some kind off mathematic mathematical expressions. So we use double in that case. So let's just just our float and double and put some values in this parables. I just died five points, 67 in double and dives the same in float, and after that I will see mistake for White. All floating point numbers in Java are double, so this number is double and it takes memory 64 bits, but we have our work piece of memory. Are were fell on Lee, so the two bits because float is started to bits and we just trying to put 60 forbids inserted to bits. So that's why I say mistake. How can I fix it? I just can it f In the end is the end off this number to say Job is that I mean float by this floating point number. After that, my float is fixed. So what's the biggest value and the smallest well you. That we can put in Flowed and Double four Florida Point types is not the extra depends how many numbers you want to save before point and after point. So if you want to say before point a lot of numbers, then after point we don't have enough for memory space and it will be just cut it and the same for the double. Just let's just put the same value. So it depends how many double the numbers we want to save before and after point. And let's just see Homan Numbers will saved Fourth Lord and double. For this. I will just use our system out print Allen to see what was saved, because actually, not all this number numbers were saved. Um, because I think we don't have enough memory to save all the oh, this number in flowed all slumbers and float, but made with have enough memory space to save all numbers in double. So now we'll just we'll see. So, as you can see in Flowed, go save the all numbers before point and only one number after point after this point and is this number was rounded to eight and yeah, I can see that I have all numbers before point and more numbers after point. But not all that they can see yet Not all numbers. So that's how works floating point types. 7. Character and boolean.: have the next two types, so we will use his bullion and character. So the 1st 1 we will try is bloom Just tie. Bouhlel is the name like Foo and the Bullet. It's such a time that can hold on the tour. Alia's true or false so I can keep put here true. Or maybe I can put here force. And how many? How do you think? How many bites beats it, Hold memory? Uh, you can suggest that only one bit, because true 40 or one bug by the fact it's four bites but, um, completely right answer That depends on you, g n, but, uh, about usual. It's four bites. So that's all about Bull. Um, our last primitive type is a character. Just type charge, See and use it. Uh, character in Java is the times that can hold one symbol one when you called symbol and because it's unique court and it can, it can hold symbols off from what from off of its from on all languages it holds in memory , 16 bits, two bites and the more interesting think the most interesting thing about character in jumbles that it's actually a number not negative, just positive number. And you can put in the character symbols numbers. Let's strike. We can put Let's add one more character. Very variable C one and this one will be Sito end in C one will good some think like 89 and in stock. We will put one symbol like if only one symbol. If I could to symbols, there will be a mistake. And let's just write it. See one and opposite. Sit down and we will see how it will be represented. So we see that white. It is a paired after 89 because 89 is the court court value four white. So, uh, character is the times that represent want symbol, but else so it's a number where you so you can use it, some kind of. So that's all about eight primitive types in Java about everything. How is that arranged in general memory? I hope you enjoyed that information and uses easier Javal life