package InputTest;
import java.util.Scanner;
public class InputTest {
public static void main(String[] args) {
// English();
Chiness();
}
public static void English(){
Scanner in = new Scanner(System.in);
System.out.print("What is your name?");
String name = in.nextLine();
System.out.print("How old are you?");
int age = in.nextInt();
System.out.println("Hello, " + name + ". Next year, you'll be "+ (age + 1));
}
public static void Chiness(){
Scanner in = new Scanner(System.in);
System.out.print("请输入你的姓名:");
String 姓名 = in.nextLine();
System.out.print("请输入你的年龄:");
int 年龄 = in.nextInt();
System.out.println("你好, " + 姓名 + ". 你明年"+ (年龄 + 1) + "岁");
}
}
英文运行效果图:
中文运行效果图:
ps:
我的idea的终端的默认字符编码是GBK,使用终端编译会报错,如下:
我的windows终端的默认字符编码也是GBK
修改当前文件字符编码后在两种终端里运行正常,如下: