java 输入输出总结
println
System.out.println源码:
/**
* Prints a String and then terminate the line. This method behaves as
* though it invokes {@link #print(String)} and then
* {@link #println()}.
*
* @param x The {@code String} to be printed.
*/
public void println(String x) {
if (getClass() == PrintStream.class) {
writeln(String.valueOf(x));
} else {
synchronized (this) {
print(x);
newLine();//输出后面额外会加一个换行;
}
}
}
Scanner
包名:import java.util.Scanner;
A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.
next()
Finds and returns the next complete token from this scanner.//会将光标定位到该字符串之后