eclipse 输入一段话,看有几个单词 比如输入 what is your name? 输出 what,is,your

1个回答

  • import java.util.Scanner;

    public class CCCC {

    public static void main(String[] args) {

    String input =null;

    Scanner nn = new Scanner(System.in);

    System.out.println("输入:");

    String a = nn.nextLine().replace(' ',',');

    System.out.println(a);

    }

    }

    上面的随手写写,也写对呀……哪有.read()?是next()吗?是nextLine()!这个好用了