1.5 Data Types and Variables
Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or
Already have an account? Sign In »

Video Transcription
00:00
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.
00:12
No, Before diving into the actual video lecture, I have a quick pre assessment question for you to test your understanding ahead of time.
00:21
Now, the question is asking you, What is Java? In technological terms,
00:26
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.
00:42
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
01:00
a computer programming language, which, as I mentioned previously, is the correct answer.
01:07
Now, I've listed out some learning objectives in this video so that you're clear on what you will be learning today.
01:14
So first we're gonna be aiming to understand where variables are in Java.
01:19
Why are variables important?
01:22
How do we declare variables in Java
01:23
and ultimately understand how we can use variables in Java?
01:30
No. What are variables?
01:33
A. Variable is a name to a given memory location. It is known as the basic unit of storage in a computer program.
01:42
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
01:57
that terrible does not exist.
02:04
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
02:20
we can perform on those specific variables or variable
02:27
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
02:38
now. Some of the primitive data types are the following
02:43
and into which stands for integer.
02:46
A float, which stands for a floating point number, which is essentially just a decimal
02:53
and a double, which is similar to a float but is more accurate than a foot.
02:59
A chart, which stands for character.
03:04
A Boolean, which either has a true or false value.
03:09
A bite, which is a unit of storage in memory,
03:16
a long which is able to store a larger number event, an ent
03:24
and a short, which is the complete opposite of it. Long it has the ability to store a shorter number
03:34
and then moving on. How do we declare variables and job
03:37
now in this image or diagram? There are all of the components that we need when declaring any sort of variable in Java.
03:46
First, we start with the data type, which you can see on the left side. Here. It states that
03:52
it is an int,
03:53
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
04:06
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.
04:16
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
04:32
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
04:53
of any type of software development in any type of language.
05:00
Now, I have a quick post assessment question for you to test your understanding after or towards the end of the Lady Electric.
05:11
Now, the question is asking you which of the following are valid data types that can be stored inside a variable.
05:16
Your options are the following either an ent
05:19
a float,
05:20
a long or all of the above. So I'm gonna go ahead and give you a few seconds to think about this.
05:30
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.
05:44
Now, just to summarize everything that we learned in this video lecture we discussed
05:48
of what variables are in Java,
05:50
white variables, variables are important
05:54
and how we declare variables
05:57
and understand how we can use variables and job
06:01
now in the video commune coming up next, we're gonna be talking about basic Earth Medic
06:08
and some basic operations that we can perform
06:11
mathematical operations. To be precise
06:15
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
Up Next
Similar Content