1

我想使用 System.out.println() 向用户询问输入。比如 System.out.println("Enter name")。但是,这会产生副作用。有没有办法绕过它?

        System.out.println("Enter name: ");
        String customerName = sc.next();
        System.out.println("Enter contact no: ");
        String contactNo = sc.next();
        accounts = (List<Account>) UserService.CreateAccount
                .apply(accounts, new Account(accounts.size() + 1, customerName, contactNo)).get();
        System.out.println("Created account with Number " + accounts.size() + "\n\n");
4

0 回答 0