[上]JAVA学习系列模块四第一章78.Scanner键盘录入_练习
视频
笔记
public class Demo01Scanner { public static void main(String[] args) { //创建对象 Scanner sc = new Scanner(System.in); //录入int型整数 int data1 = sc.nextInt(); System.out.println("data1 = " + data1); //录入String型字符串 String data2 = sc.next(); System.out.println("data2 = " + data2); } } ==================================================== public class Demo02Scanner { public static void main(String[] args) { //创建对象 Scanner sc = new Scanner(System.in); //录入int型整数 int old1 = sc.nextInt(); int old2 = sc.nextInt(); int old3 = sc.nextInt(); int temp = old1>old2?old1:old2; int max = temp>old3?temp:old3; System.out.println(max); } }