public void Algorithm_6(){
Scanner inputData = new Scanner(System.in);
inputData.useDelimiter("\n");
System.out.print("请输入字符串:");
String data = inputData.next();
System.out.println("字符串长度为"+data.length());
System.out.println("字符串为"+data);
inputData.close();
}
如下图,我输入了字符串 "1234", 输出字符串长度却为5