1、需要传参:System.in
2、scanner.next()接收字符串类型
3、scanner.nextInt()接收整型
package com.ke.demo1; import java.util.Scanner; public class demo1 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); System.out.println("输入姓名:"); String name=scanner.next(); System.out.println(name); System.out.println("输入年龄:"); int age=scanner.nextInt(); System.out.println(age); } }View Code
标签:scanner,System,Scanner,nextInt,println,out From: https://www.cnblogs.com/kezhang/p/16838378.html