Java Basics

Java Basics 03: variables

14 videos

80 minutes

For in this video we will begin to see the types of variables, which are in Java and the first thing I say is do not confuse Java with JavaScript, They are different languages ​​that have nothing to do on many issues and one of them is the case of variables, so this is very different, go with Java. Programs to work must have saved data, need information to work with, that information must be stored in

variables. Variables are memory areas in which such data are received and stored. Each data is different, is not the same store a string text, numbers and even within the numbers, is not the same store an integer number with decimals. So, each data type still corresponds different type of variable, because they are different forms of data and there are different ways to store, okay? Then, I'll show you in

Java, what are the main types of variables that are to store the data. There are many, but let's look at the most basic, since this is a beginner course. If you want to save an integer, we use the word int, there are telling Java that we save is an integer and then we say how we're going to call that thing; for example, we'll call number, okay? If we want to save a number with decimals, we would double and

after data name. For example, I can call decimal, decimal although, here, you could put for example, height and that we would give as measures a Person: 1.77, for example, and there would have a number with decimal. If we want to save a string, we would String and string, okay ?, String forgiveness with capital letter; now there does not fail, String and string. And then we have one last thing that is Boolean, which are values ​​that can only have two

options within this type of data, or true or false; or true or false, only it serves to say whether something is in one way or another, if on or off. True or false, this will, as for example a switch, no. If it is turned on or off, true or false, what would be the thing. Java to save this data, what we do is the following, with the same operator, assign values, eg number, we number equal to

five; everything is ok. If I say, look, number equal to 4.6, it gives me an error, they saw that gives me an error; because I said that number is an integer and I am giving a decimal figure and that can not be. If I want a decimal, I have to save it in a variable of type double, as it is decimal, there itself gives no mistake, they saw. And, I can save decimal decimals and integers; there is no problem. The thing is, if I want to save decimals, must be in a

variable of type double. In this variable I can not keep a text string, because it is not reserved for it, decimal is not ready to save text strings, you are ready to store numbers; then here we would have to put the string variable that is a string and there indeed has this can give you text string values. And then the Boolean variable, switch, we can give you a true, there you have it; true or false, or false; there it is. in future

videos will see how to use Boolean variables, in fact, in the video below, where we see a little and then we will see If logical operators; well We try a little booleans, but when this video stay with these ideas, there are different types of data, and each data has to go with a variable dedicated to it. For integers: int, for numbers with decimals: double, for text strings: String and Boolean: boolean.

And we'll see from the following videos. A greeting.

To find new courses, subscribe. There will be no spam, promised :)

About the Author

foto de jotajotavm
José Javier Villena

Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.