用Scanner输入东西后,如何使用nextline来读取输入的多行字符?
请朋友们写一个简单的例子来看看,我脑袋一下短路没印象了。

解决方案 »

  1.   

    import java.util.Scanner;public class ScannerTest { public static void main(String[] args) {
      Scanner s = new Scanner(System.in);
      //receive string
      String str = s.next();
      
      //receive integer
      Integer i = s.nextInt();
      
      //receive double
      Double d = s.nextDouble();
      
      System.out.println(str+i+d);
     }
    }
      

  2.   

    大概明白了,就是说,在用next读取的时候,程序读完当前这段后,就不再读这段字符了,下次再使用next的时候就会自动读接下来的字符?
      

  3.   

    不对,搞混了,readline才是这样读的。。
    混乱了
      

  4.   

    抱歉,是我搞错了,我把它和readline搞混了。
    不管他了,只要知道如何用next()方法就可以了。
    谢谢大家。