Popular Google Pages:
◕ Bengali Story writing competition. More..
This article is regarding Use of Underscores to write an integer in Java.
Last updated on: 4th February 2017.
◕ Use of Underscores to write an integer in Java.
We insert underlines to make the literal easier to read.
The explanation and the example are given bellow.
In Java we can write integer within 4 types. They are:
To write a long type integer we have to write:
long stars = 9876543210L; // a Java statement
The L in the suffix of the number indicates that it a long type integer.
When we write a long type integer like this 9876543210L it sometimes looks difficult to read. Hence to make it easy to read use the Underscores like 9_876_543_210L.
But there are some rules to use Underscores.
- 1) We can use multiple Underscores in a integer type.
long stars = 9__876__543__210L;
- 2) The both side of the Underscore / Underscores must be bound by digits or Underscore.
Related Java articles:
■ What is Java? Where we can apply Java?
■ Why Java is a Machine Independent Program? What is Machine Independent Program?
■ Root Directory of Java
■ How to Compile and run a Java Program?
■ What is .class file in Java?
■ What is variable in a program?
■ What is identifier in Java?
■ Integer data types in Java?
■ What is Primitive Types in Java?
■ How to declare constant variables in Java?
■ Why should we declare the initial value of a variable in Java?
■ Use of Underscores to write an integer in Java
Top of the page