win7 java 键盘输入语句 比如输入两个数字2,3分别赋值给m,n,最后输出格式是m=2;n=3
1个回答
展开全部
可以使用Scanner类,取得键盘输入。代码如下:
import java.util.Scanner;
public class TestScanner {
public static void main(String[] args){
System.out.println("please input an integer ...");
Scanner scanner = new Scanner(System.in);
int m = scanner.nextInt();
System.out.println("please input another integer ...");
int n = scanner.nextInt();
System.out.println("m = " + m + " n = " + n);
}}
import java.util.Scanner;
public class TestScanner {
public static void main(String[] args){
System.out.println("please input an integer ...");
Scanner scanner = new Scanner(System.in);
int m = scanner.nextInt();
System.out.println("please input another integer ...");
int n = scanner.nextInt();
System.out.println("m = " + m + " n = " + n);
}}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |