Java Programming Tutorial | Data Types in Java | GeeksforGeeks

Hello viewers, welcome to GeeksforGeeks. In
this tutorial we’ll learn about the Data types in JavaJava is statically typed and also a
strongly typed language because in Java, each type of data (such as integer, character,
hexadecimal, packed decimal, and so forth) is predefined as part of the programming language
and all constants or variables defined for a given program must be described with one
of the data types.Java has two categories of data: Primitive data (e.g., number, character)
and Object data (programmer created types)These
are 8 types of primitive data in java. boolean, byte, char , short , int, long, float, double.
We will learn about each one of them in coming slides.First let’s look at boolean data type.
boolean data type represents only one bit of information either true or false. Boolean
in defined as this, in java. Here b is the identifier for the boolear data type. We initialize
it with true. If b==true then we will print Hi geek. So as we have set our value as true
here, therefore this statement is true. Thus it would print Hi geek.byte.. The byte data
type is an 8-bit signed two’s complement integer.The byte data type is useful for saving
memory in large arrays. The Size of byte is 8-bit, its value lies between -to This is
how we initialize byte in java. We saved in it. When we print a we will get We can add
one in a and it would print in this statement.short.. The short data type is a 16-bit signed two’s
complement integer. Similar to byte, we use a short to save memory in large arrays. Its
value lies between -32,to 32,int.. It is a 32-bit signed two’s complement integer.
The Size of int is 32-bit, its value lies between -2^to (2^31)-long: The long data type
is a 64-bit two’s complement integer. Its value lies between -2^to (2^63)-float, The
float data type is a single-precision 32-bit, its basically used to store decimal values.
F/f suffix is used along with it, for Example: 9.The double data type is a double-precision
64-bit.char, The char data type is a single 16-bit Unicode character. A char is a single
character. Its value lies between 0 to 65,This how we declare each of this data type in java.
We start with the data type like char, or int, etc then its indentifier like i in this
case, then you may specify its value. Pause the video and take a look at all of them.Thank
you, for watching. Please leave us your likes and comments.

2 thoughts on “Java Programming Tutorial | Data Types in Java | GeeksforGeeks

Leave a Reply

Your email address will not be published. Required fields are marked *