菜鸟提问
怎样控制字符串的输入?(现在不知道要输入多少个字符串,数量由自己控制)
[解决办法]
public static void main(String[] args) { try{ int a = 0; Scanner scanner = new Scanner (System.in); System.out.println("输入字符串个数是?:"); a = scanner.nextInt(); for (int n = 0; n <a; n++) { String temp = scanner.nextLine(); System.out.println("第" + (n+1) +"字符串是?:" + temp); } catch(Exception e){ System.out.println("输入错误"); } }