Data Types and Variables - Java

Data Types and Variables - Java

Just includes the data types and basic knowledge of Variables

In this blog, we are going to learn about the data types and variables in the Java Programming language. Please try to focus on these concepts only, we are going to cover all the topics which are related to this declaration backend process in the right next upcoming blog in which we cover topics like input, output, and memory utilization in the Java programming language.

Variables:

Variables are the containers in memory that holds your data. That could be user-provided or by the programmer. It helps to store your data in a container by which you can utilize that data in any block of the program. Again, how these variables work, will be covered in the upcoming blog.

To declare the variables in java, we data type indication before we name them.

Data Type:

As its name suggests, it represents the type of data in our programming language. We deal with a lot of data in real-world problem solving, but when you need to store it in the memory we actually need to sort them based upon their data type. As we know that everything in programming can be finally stored in the binary, to let avoid confusing the compiler of Java, we used to declare the variable with its data actually what it's going to store in it.

The syntax of declaring a variable:

int number;

Here, we just mentioned the type of data going to be stored in the variable called number.

In java programming, we have several data types:

These are generally categorized into Primitive data types,

int, float, char, byte, long, short, boolean, and double.

Byte, short, int, and long represent holding integer values in it (whole numbers).

Float and double to represent the real numbers.

A variable of type char holds a single character from the Unicode character set.

Boolean can hold logical values that represent true or false.

Rules for naming a variable

  1. Don't name a variable that starts with a number (We are not allowed to declare a variable with the name 1_variable)

  2. Don't name a variable that is equal to any keyword in java programming.

Please take it as a reference for the upcoming blogs on Java. It is only to separate the entire series of a blog which can actually help you to remember the data types and basics of variables.

Did you find this article valuable?

Support ManjuBlogs by becoming a sponsor. Any amount is appreciated!