编译器:eclipse
最近学习算法第四版,在写代码过程中发现输入按了enter之后也没有反应。
已经安装好了algs4库。
找到最新的选择排序并运行:https://algs4.cs.princeton.edu/21elementary/Selection.java.html
在运行时按了enter也没有反应。
查看readallstrings源码也没有分析出原因了。
/**
* Reads all remaining tokens from this input stream and returns them as
* an array of strings.
*
* @return all remaining tokens in this input stream, as an array of strings
*/
public String[] readAllStrings() {
// we could use readAll.trim().split(), but that's not consistent
// since trim() uses characters 0x00..0x20 as whitespace
String[] tokens = WHITESPACE_PATTERN.split(readAll());
if (tokens.length == 0 || tokens[0].length() > 0)
return tokens;
String[] decapitokens = new String[tokens.length-1];
for (int i = 0; i < tokens.length-1; i++)
decapitokens[i] = tokens[i+1];
return decapitokens;
}
求解,感激不尽。