Java Variables.

We can think about java variable, it is just like a cup, in examples, coffee cups, teacups, giant cup that holds lot of liquids. This variable is a container hold the something.

It has size and types. This cup can hold primitives and reference to objects. Primitives are come with the difference sixes and each name like short, tall like this.

Java Variables

These primitives come with the difference sixes and names.

You are declaring the variables in the java and you should it with specify the type.

The above cup for is showing the four-integer primitive in the java with the size example.

This each primitive variables have a fixed number of bits. The sizes for the six numbers of primitives in java as follows.

Java Variables

Types of variables.

Local Variables – Local Variables are a variable we can declare them inside the body of a method.

Instance Variables – Instance variables we can define without the STATIC keyword. We can define this variables outside a method declaration. They are Object specific and instance variables.

Static Variables – Static variables we can initialize only once, at the start of the program execution. These variables should  initialize first, before the initialization of any instance variables.

Data type in the Java.

Data Types in Java we can define as specifiers that allocate different sizes and types of values that we can stored in the variable or an identifier. Java has a rich set of data types. Data types in Java we can divide into two parts.

  1. Primitive Data Types: – This include integer, character, Boolean, and float
  2. Non-primitive Data Types: – Which include classes, arrays, and interfaces.
Primitive Data Types.

This types we should predefine and available within the Java language. Values do not share state with other primitive values.

Integer data types .                      
float (4 bytes)
 
double (8 bytes
Floating Data Type.

byte (1 byte)

short (2 bytes)

int (4 bytes)

long (8 bytes)

Textual Data Type.
char (2 bytes)
Logical.
boolean (1 byte) (true/false).

Java Tutorial Part 01.

2 thoughts on “Java Variables.”

Leave a Reply

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