public class Main { public static void main(String[] args) { try { // create a BufferedReader object to read input from console BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

  // prompt the user to enter their name
  System.out.print("Enter your name: ");

  // read the user's input
  String name = reader.readLine();

  // print a greeting message to the user
  System.out.println("Hello, " + name + "!");

} catch (IOException e) {
  System.out.println("An error occurred: " + e);
}

}

import javaio;

原文地址: https://www.cveoy.top/t/topic/cvYc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录