//jdk 1.7
version Concept:----------------------
//Underscores Between Digits in Numeric Literals
package govind;
public class UnderScorePass {
public static
void main(String[] args) {
int carloan=10_00_00_00;
int homeloan=10_0000_00_00;
System.out.println("Car
Loan="+carloan);
System.out.println("Home
Loan="+homeloan);
//String s1="12_12";
//int x=Integer.parseInt(s1);//error
}
}
o/p:------------
Car Loan=10000000
Home Loan=1000000000
Underscores Between Digits in Numeric LiteralsUnderscores
are permitted in numeric literals.
You can place
underscores where you feel required to increase readability
like between
hundreds and thousands, thousands and lakhs etc.
This is used to group numbers in a bigger literal value
(especially of long data type).
Note: Do not place underscore at the beginning or ending
of the literal value.
Note: But following does not work (cannot parse with underscores).
//String
s1="12_12";
//int x=Integer.parseInt(s1);//error
No comments:
Post a Comment