while (!sc.nextLine().equals("")){ text[i] = sc.nextLine(); i++; }这将从您的输入中读取两行:一行与空字符串进行比较,然后另一行实际存储在数组中。您希望将行放入变量中,以便
String在两种情况下都可以进行检查和处理:
while(true) { String nextLine = sc.nextLine(); if ( nextLine.equals("") ) { break; } text[i] = nextLine; i++;}


