I am trying to get this method to which I introduce a message as a parameter to return a positive integer, I also have to use a try-catch so that it asks me until I insert a correct value. It gives me an error when putting the return inside the try.
public static int enteroPositivo(String mensaje){
int entero = 0;
do{
try{
System.out.println(mensaje);
Scanner scan = new Scanner(System.in);
entero = scan.nextInt();
return entero;
} catch (Exception e){
System.out.println("Por favor, introduzca un valor correcto.");
}
}while (entero>0);
}