VARIABLES
Hello everyone I hope you’re doing great today it’s our next
tutorial on java programming. We are going to deal with Variables and data
types.
What is a variable?
These are objects that store data for processing in
programming. So when dealing with variables we must give them names so as we
can identify them when we need something we stored in them. We don’t recommend
repeating names for the variables we created because it will cause confusion
when we need them. As said earlier we store data through Variables have you
asked yourself about the type of data?
When we store data in variables we need to assign them with
their data types so as to make the device executing the codes to exactly know
how to deal with the data we stored.
LINK TO THE VIDEO
Here are the data
types we use in Java.
·
BYTE
Is the smallest data type based
on the list of data types in java. It’s an 8-bit signed complement integer that
can store whole numbers from -128 to127 only per one byte remember keeping it
into practice will work you best.
·
SHORT
It’s a 16-bit data type which can
store data whole numbers from -32,768 to 32,767 you can use short to save
memory in large arrays
·
INT
Now you’re free to forget about
the above. An int is the most commonly used data type which can store a minimum
value of 2-31 and a maximum value of 231. You might ask why we use them mostly
in java than other data types it’s because we need support in the arithmetic
operation for integers.
·
LONG
The long data type is a 64-bit two complement
integer. The signed long has a minimum value of -263 and a maximum value of
263-1. We use this data type when we need a range of values wider than those
provided by int which it most cases it’s difficult for such thing.
·
FLOAT
Is a data type in a
single-precision 32- bit floating integers. As with the recommendations for byte
and short use float (instead of double) if you need to save memory in large
arrays of floating-point numbers.
·
DOUBLE
Is a double-precision 64-bit
floating point for decimal values, this type is generally the default choice.
When you pass through codes that
are dealing with the currency you will notice that they are using double data type.
·
BOOLEAN
Let we get back in high school
you ever heard of Boolean values didn’t you used in digital circuits and logic
in mathematics, the same applies here we have only two things on Boolean data types
it's either true or false
·
CHAR
Is a single 16-bit Unicode the character that can only store a single character/letter or ASCII value.
And the must be in a single quote
(‘char goes here’)
·
STRING
We discussed strings on the last post.
We made it independent because it’s super important and used a lot in java
language. Anyway, it’s used to store words or names or characters and it is
placed on double quotes (“string goes here”).
LINK TO THE VIDEO;
THANK YOU FOR KEEPING INTOUCH:
Comments
Post a Comment