集册 Java实例教程 通过扫描仪读取字符串

通过扫描仪读取字符串

欢马劈雪     最近更新时间:2020-01-02 10:19:05

446
通过扫描仪读取字符串
/* 来自 nowjava.com - 时代Java*/


import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in); // use the Scanner class to read from stdin

        System.out.println("What's your input string?");

        String inputString = scan.nextLine(); // read a line of input and save it to a variable

        scan.close(); // close the scanner


        // Your first line of output goes here

        System.out.println(
展开阅读全文