标签:string stat ring main import tin scan public bsp
package mypro01; import java.util.Scanner; /** * 测试scanner类,如何接受键盘的输入 * @author 4090039qrh * @version 10.0.2 */ public class TestScanner { /** * 键盘输入字符串 */ public static void test01() { Scanner s = new Scanner(System.in); String str = s.next();//next会等待键盘的输入字符串 System.out.println("输入:"+str); } public static void test02() { Scanner s = new Scanner(System.in); System.out.print("加数: "); int a = s.nextInt();//nextInt会等待输入整数 System.out.print("加数: "); int b=s.nextInt(); int sum = a+b; System.out.println("和为:"+sum); } public static void main(String[] args) { test01(); test02(); } }
标签:string stat ring main import tin scan public bsp
原文地址:https://www.cnblogs.com/hapyygril/p/12344527.html