这个String类的使用做这个怎么做,我做出来的和这个结果不一样,好疑惑

img


package test;

import java.util.Scanner;

public class Register {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.print("请输入用户名:");
            String name = sc.nextLine();
            System.out.print("请输入密码:");
            String pw1 = sc.nextLine();
            System.out.print("请再次确认密码:");
            String pw2 = sc.nextLine();
            if (verify(name, pw1, pw2)) {
                System.out.println("注册成功!请牢记用户名和密码");
                break;
            }
        }
    }

    public static boolean verify(String name, String pw1, String pw2) {
        if (name.length() < 3 || pw1.length() < 6) {
            System.out.println("用户户名长度不能小于3, 密码长度不能小于6!");
            return false;
        } else if (!pw1.equals(pw2)) {
            System.out.println("两次输入密码不相同!");
            return false;
        } else {
            return true;
        }
    }
}

运行效果

img