Java?Scanner???????nextInt()
,nextDouble()
,nextFloat()
??????????????,??????????????,????java.util.Scanner.format()
???
???????Scanner.format()
?????:
import java.util.Scanner; import java.util.Scanner.Format; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("???????(??:???):"); int number = scanner.format("d", scanner.nextInt()).intValue(); System.out.println("???????:" + number); System.out.println("???????(??:????):"); double decimal = scanner.format("f", scanner.nextDouble()).doubleValue(); System.out.println("???????:" + decimal); scanner.close(); } }
??????,????d
?f
???????d
??????????,???????,?????0???f
????????????,????????,?????0???
??:scanner.format()
???????????,????????intValue()
?doubleValue()
???????????????