Hi and welcome back to the course Now, In the previous video, we went over creating our very first program in Java. And in this video, we're gonna be talking about data types and variables in Java.
No, Before diving into the actual video lecture, I have a quick pre assessment question for you to test your understanding ahead of time.
Now, the question is asking you, What is Java? In technological terms,
your options are either a language used for communication, coffee, a computer programming language or none of the above. So I'm gonna go ahead and give you a few seconds to think about the answer.
Now, if you selected see a computer programming language, that is absolutely correct. It is definitely not a language use for communication. It is not coffee. Java is a type of coffee, But we're asking what Java is in technological terms. And then that leaves us with the auction. See
a computer programming language, which, as I mentioned previously, is the correct answer.
Now, I've listed out some learning objectives in this video so that you're clear on what you will be learning today.
So first we're gonna be aiming to understand where variables are in Java.
Why are variables important?
How do we declare variables in Java
and ultimately understand how we can use variables in Java?
No. What are variables?
A. Variable is a name to a given memory location. It is known as the basic unit of storage in a computer program.
Now in Java, all variables have to be declared or defined before we actually use them. Because if you don't define a variable or declare variable before you're using it, your program is going to give you an error stating that
that terrible does not exist.
So here are some valid data types for variables. But before actually going into the data types, some of you might don't know what a data type is. So just to cover that a data type determines the value or values that the variable can take on and what kind of operations
we can perform on those specific variables or variable
in Java, we have something called primitive data types, and these are the most basic data types available within Java that any of our variables that we make can make use of
now. Some of the primitive data types are the following
and into which stands for integer.
A float, which stands for a floating point number, which is essentially just a decimal
and a double, which is similar to a float but is more accurate than a foot.
A chart, which stands for character.
A Boolean, which either has a true or false value.
A bite, which is a unit of storage in memory,
a long which is able to store a larger number event, an ent
and a short, which is the complete opposite of it. Long it has the ability to store a shorter number
and then moving on. How do we declare variables and job
now in this image or diagram? There are all of the components that we need when declaring any sort of variable in Java.
First, we start with the data type, which you can see on the left side. Here. It states that
and then we give our variable a name. In this case, it's a JJ, then falling that we have the assignment operator or the equal sign, and then we assign it a value, which in this case is 20
now. 20 is the value that's reserved in memory for the variable or put in the ram or also known as a random access memory.
So why is it that we use variables now when we make different sorts of programs? Sometimes or often times we have to store a certain things values, numbers, measurements and
data and all of a lot of that stuff. And for that, we use of variables because when we store anything in a variable, we have the ability to manipulate it at onto it, remove it, which essentially helps out with the entire functioning off our program, which makes it a crucial part
of any type of software development in any type of language.
Now, I have a quick post assessment question for you to test your understanding after or towards the end of the Lady Electric.
Now, the question is asking you which of the following are valid data types that can be stored inside a variable.
Your options are the following either an ent
a long or all of the above. So I'm gonna go ahead and give you a few seconds to think about this.
Now if you selected all of the above that that is the correct answer. An end and they float in a long are all balladeer types that we can use to store inside a variable.
Now, just to summarize everything that we learned in this video lecture we discussed
of what variables are in Java,
white variables, variables are important
and how we declare variables
and understand how we can use variables and job
now in the video commune coming up next, we're gonna be talking about basic Earth Medic
and some basic operations that we can perform
mathematical operations. To be precise
now is always if you have any questions at all or want to connect with me, you can feel free to join my Lincoln below. And I would be more than happy to answer any of your questions. And I look forward to seeing you in the next video lecture. Thank you very much for watching