//Java 实现
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// 从输入读取单行. 例如: Hi there!
System.out.print("Enter a line: ");
String line = scanner.nextLine();
System.out.println("You entered: " + line);
// 输出结果为: You entered: Hi there!
// 读取一个整数. 例如: 08081990
System.out.print("Enter an integer: ");
int number = scanner.nextInt();
System.out.println("You entered: " + number);
// 输出结果为: You entered: 08081990
scanner.close();
}
}
// 读取一个字符串. 例如: Charlotte
val name = readln()
// 读取一个字符串, 并转换为整数. 例如: 43
val age = readln().toInt()
println("Hello, $name! You are $age years old.")
// 输出结果为: Hello, Charlotte! You are 43 years old.