java 7 - How to print/scan Underscores in Numeric Literals -
team,
i not able use java 7 underscores in numeric literals feature getting input user , printing out in same format declared. please in doing that? or feature incomplete?
scanner input = new scanner( system.in ); int x = 1_00_000; system.out.print( "enter numeric literals underscores: " ); //2_00_000 x = input.nextint(); //java.util.inputmismatchexception system.out.println(x); // prints in normal format, want in 2_00_000.
note: in eclipse; able change value of numeric literal underscored numeric literal in runtime. may hack, needed feature input underscored numeric literal in runtime rit?.
http://www.eclipse.org/jdt/ui/r3_8/java7news/whats-new-java-7.html#miscellaneous
if want maintain underscores can use string:
scanner input = new scanner( system.in ); system.out.print( "enter numeric literals underscores: " ); //2_00_000 string stringliterals = input.nextline(); system.out.println(stringliterals); // prints 2_00_000.
Comments
Post a Comment