2. คำนวณ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 2-20  การเรียก nextLine ตามหลัง nextInt, nextDouble หรือ next
    Scanner kb = new Scanner(System.in);
    System.out.print("กรุณาใส่จำนวนเต็ม > ");
    int n = kb.nextInt();
    System.out.print("กรุณาใส่ข้อความ > ");
    String s = kb.nextLine();
    System.out.println(n + ", " + s);
©2009 S.Prasitjutrakul