Using underscore in Numeric Literals in Java Last Updated : 02 Mar, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report A new feature was introduced by JDK 7 which allows writing numeric literals using the underscore character. Basically, they are broken to enhance readability. This feature enables us to separate groups of digits in numeric literals, which improves the readability of code. For instance, if our code contains numbers with many digits, we can use an underscore character to separate digits in groups of three, similar to how we would use a punctuation mark like a comma, or a space, as a separator. Let us explore further with an example Example Java // Java Program to Illustrate Different Ways of Usage // of Underscore in Numeric Literals // Main class class GFG { // Main driver method public static void main(String[] args) throws java.lang.Exception { // Declaring and initializing values of // integer, long, float and double datatype // Integer literal int inum = 1_00_00_000; // Long literal long lnum = 1_00_00_000; // Float literal float fnum = 2.10_001F; // Double literal double dnum = 2.10_12_001; // Printing and displaying values on console System.out.println("inum:" + inum); System.out.println("lnum:" + lnum); System.out.println("fnum:" + fnum); System.out.println("dnum:" + dnum); } } Outputinum:10000000 lnum:10000000 fnum:2.10001 dnum:2.1012001 Comment More infoAdvertise with us Next Article Widening Primitive Conversion in Java K kartik Improve Article Tags : Java java-basics Practice Tags : Java Similar Reads Using _ (underscore) as Variable Name in Java As we do know variables in java or rather in any language is introduced to write a code where it is suggested to give meaningful names to the variables as per their usage in code and especially in object-oriented languages are supposed to be used locally wherever it is possible instead of just using 3 min read Literals in Java In Java, a Literal is a synthetic representation of boolean, numeric, character, or string data. It is a medium of expressing particular values in the program, such as an integer variable named "x" is assigned an integer value in the following statement.// Here 100 is a constant/literal.int x = 100; 6 min read Widening Primitive Conversion in Java Whenever we do use double quotes around a letter or string as we all know it is treated as a string but when we do use a single quote round letter alongside performing some computations then they are treated as integers values while printing for which we must have knowledge of ASCII table concept as 3 min read Array Literals in Java Literal is just unlikely any constant value that can be assigned to a variable. Illustration: int x = 10; // Here 10 is a literal. Now let us stick to the array literals that are just like primitive and string literals java also allows us to use array literals. Java defines special syntax that allow 3 min read Numbers in Java (With 0 Prefix and with Strings) Consider the following Java program. Java import java.io.*; class GFG { public static void main (String[] args) { int x = 012; System.out.print(x); } } Output: 10 The reason for above output is, when a 0 is prefixed the value is considered octal, since 12 in octal is 10 in decimal, the result is 10. 1 min read Integer toString() in Java The java.lang.Integer.toString() is an inbuilt method in Java which is used to return the String object representing this Integer's value. Syntax : public static String toString() Parameters: The method does not accept any parameters. Return Value:The method returns the string object of the particul 5 min read Like