新手求助:怎样从控制台读入一个整型/浮点型?
如题,即是问JAVA里有没有相当于C里scanf或C++里cin的东西?
------解决方案--------------------Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
float f = sc.nextfloat();
------解决方案--------------------import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
System.out.println(i);
float f = sc.nextFloat();
System.out.println(f);
}
}