Switch to full style
Java Technology Tutorials Written By Members.
Post a reply

add underscore between the digits numbers

Mon Nov 05, 2012 5:04 pm

Starting from JDK7 you are allowed to put underscores between the digits number in primitives initialization step.In goal of increasing the readability of your java source code, at Java7 you can add underscore between the digits numbers for example:

Code:
long cardNumber = 3234_5431_6441_9876L; 
double mydouble
=323_123_3d;
Integer integer=32_43; 

There are places that you have to be careful about putting underscore there:
  • Before the Suffix (L or D).
  • At the start or end of a number.
  • Place of String of digits is required.
  • Before or after the floating point.
Example of a wrong usage for underscore with numbers assignment:
Code:
float fnumber = 53_.32F;
long VisaCard= 1111_1111_1111_L;
int intNum = _12;
 




Post a reply
  Related Posts  to : add underscore between the digits numbers
 add two 24-bit numbers (sum two numbers)     -  
 Complex Numbers     -  
 JProgressbar Sum of 'n' Numbers     -  
 The harmonic mean of two numbers is given by     -  
 The harmonic mean of two numbers is given by:     -  
 add sequence of decimal numbers     -  
 swap two numbers c++ program     -  
 Complex numbers calculator (C++)     -  
 multiply two numbers in PIC assembly     -  
 Remove ordered list numbers     -  

Topic Tags

Java Basics