qualcuno mi spiega per favore come controllo in java che input riceve solo stringa non numeri
perchè il mio programma non da nessun errore se inserisco un numero perchè ? grazie mille
codice:
package studentClassPackage;
import java.util.Scanner;


public class studentClass {
    
    private String stuName;
    
    public void setStudentsName(){
        Scanner studentInputName = new Scanner(System.in);
        System.out.print("\t\tEnter student name --> ");
        if(studentInputName.hasNextLine()){
            this.stuName = studentInputName.nextLine();
        }else{
            System.out.println("\t\tInvalid input supply");
        } 
    }
    
    public String getStudentName(){
        return this.stuName;
    }
}