You might have often read the term variable when it comes to programming languages. We will be talking about variables in the purview of Java as the programming language. A variable is nothing but name for a memory location. They can be classified into three types based on where they are declared. Local variables are inside a method , instance vari...

Read More

Initializing or assigning a value to a variable can be done in multiple ways. The most common one is declaring and initializing the variable in the same line. int a=10; Multiple initialization can be done in the same line as well but the caveat is that all the variables have to be of the same type. This can be done as below int a, b, c=10; //he...

Read More

Static variable: Class variables are called static variables. There is only one occurrence of a class variable per JVM per class loader. When a class is loaded the class variables (or static variables) are initialized. A static variable is used in the singleton pattern. A static variable is used with a final modifier to define constants.  Instance ...

Read More

Type casting basically refers to having a variable of one type behave as another type. Java automatically takes care of Upcasting, in the below mentioned order of hierarchy, from left to right. byte → short → int → long → float → double On the other hand if a cast is attempted between types occurring in the order from right to left, then downcast...

Read More

Arrays in Java are very different from how they used to be in C++. An array in Java is an complex data type which can store data of any type. This data type needs to be defined along with the array size at the time of declaration. The associated data type can be a primitive type or a Class. However once the array is declared it can hold data of onl...

Read More

To iterate over an array you can just loop through it using the array index or using the for each loop meant for collections. The maximum index will be one less than length of the array. Reading a value from an array is very simple, just get it by providing the index of the element. While doing so do take care about not exceeding the size of the ar...

Read More

BitSet is a Data structure provided by java.util package. This class implements a vector of bits that grows when required. It is used to efficiently store a lots of on-off information. The internal data store of a BitSet is as following: // The internal field corresponding to the serialField "bits". private long[] words; So BitSet stores the dat...

Read More

The floating data type represent the floating numbers that means numbers with decimal point .For example: 10.45, 5.14, 0.005, -125.12 etc. There are 2 types of floating datatypes available in Java: float double The following table shows the memory size and range of float and double.   sl.no     Datatype       Memory size    Range 1 Float 4bytes   -...

Read More

The keyword volatile refers to concurrency. This keyword is useful when there are many threads trying to read the value of a variable. When a variable is marked as volatile, the value of that variable is written and read from the main memory. To understand the concept in detail, we need to have clarity in the following concepts. When working with T...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself