java中返回值和截取问题,可以帮我看看哪里错了吗?

这个题目的要求是,scanner方法输入一个密码,当密码是5位以上时输出5位以上的部分,当密码是5位一下时输出完整密码图片说明

这是我写的代码,想不通哪里错误了,求求帮帮

先判断大小在决定是否截取,不然会报越界异常
public static void main(String[] args) {
while (true){
System.out.println(recive());
}
}

public static String recive(){
    Scanner scanner = new Scanner(System.in);
    System.out.println("请输入密码:");
    String pwd = scanner.next();
    int length = pwd.length();
    if (length > 5){
        return pwd.substring(5);
    }
    return pwd;
}

    Scanner ps = new Scanner(System.in);
        String password = ps.next();
        int length = password.length();
        if (length>5){
            String xc = password.substring(5);
           return xc;
        }
        else{
            return password;   
        }
//还有你没打印,当然没结果,你怎么知道对错的
System.out.println(recive());