读写
Scanner in = new Scanner(System.in);
in.next();
in.nextInt();//根据数据类型选择nextXXX,float,double
in.nextLine();
System.out.println("");
System.out.print("");
System.out.printf("%4.2f", i);// "4.2"中4表示输出的长度,2表示小数点后的位数。
System.out.printf("%d", i);// "d"表示输出十进制整数。
%d表示打印整型的,
%2d表示把整型数据打印最低两位,
%02d表示把整型数据打印最低两位,如果不足两位,用0补齐
关于scanner中的next
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
in.readLine();
static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
out.write(" ");
int s = in.read(); // 读入一个字符 可读入空格回车 但不抛弃回车
String s1 = in.readLine(); // 读入一行 可读入空格可读入回车 但会将回车抛弃
String s2[] = in.readLine().split(" "); // 使用Split通过空格分割读入的一行字符串,存在s2中
//测试write 不能直接输出int类型
int a = 65;
out.write("\n");
out.write(a + "\n"); // 使用 + 号拼接个字符串 使参数整体为一个字符串
out.write(Integer.toString(a)); // 输出a的字符串形式
out.write("\n");
//测试 read() 和 readLine();
int b = in.read(); // read()只读取一个字符
int c = in.read(); // 吸收 \n
int x = in.read(); // 吸收 \r
BigInteger
//实例化
BigInteger a = new BigInteger("1");