Range and behavior of its primitive types - Java

Why does Java strictly specify the range and behavior of its primitive types?

Java strictly specifies the ranges for primitive values. The selection of values in integer or floating point types differs based on the requirement of an application. Developers need not always use int type to handle any integer values. By having the ranges, Java allows developers to utilize the facilities on primitive types in wise manner. For example to use the integer constant 39, it is not wise to represent long or int or even short as it is available in byte type and occupies 8 bits of memory space. By using it as int type, 32 bits of memory space need to be used. Hence there will be a performance issue. Thus the range of primitive types plays a vital role in a Java application performance.
What is Java’s character type?
The char data type in Java is a single 16-bit Unicode character. It represents a character that could be any one of the world languages...
Difference between the prefix and postfix forms - Java
The prefix operator ++ adds one to its operand / variable and returns the value before it is assigned to the variable. In other words, the increment takes place first and the assignment next...
String methods indexOf() and lastIndexOf() - Java
The method indexOf() returns the first occurrence (index) of a given character or a combination as parameter in a given string...
Post your comment