Java输入
键盘输入:
可以用Scanner类创建一个对象:
Scanner reader = new Scanner(System.in);
reader对象用于调用各种方法完成输入类型;
1:nextBoolean()
2:nextByte()
3:nextShort()
4:nextInt()
5:nextLong()
6:nextFloat()
7:nextDouble()
import java.util.Scanner;
Rect rectangle = new Rect();
Scanner reader = new Scanner(System.in);
System.out.printf("请输入矩形的宽,并回车确认");
rectangle.width = reader.nextDouble();