Aprendiendo a verificar si el tipo de dato existe con Java ['ESP' ,'ENG']

Por el momento sigo aprendiendo como autodidacta este increíble lenguaje de programación, que posee muchos métodos y maneras muy estrictas de declarar ocurrencias.
Al venir de un lenguaje de programación muy flexible, Java me obliga ser muy explícito y declarar exactamente que debe ocurrir.

At the moment I am still learning this incredible programming language as a self-taught person, which has many methods and very strict ways of declaring occurrences. Coming from a very flexible programming language, Java requires me to be very explicit and declare exactly what should happen.

valid1.jpg

En este caso me surgió una intriga por saber cómo verificar si la función “Scanner” puede verificar si un dato es ingresado u no, al parecer se debe consultas si el tipo de dato ingresado por la consola existe y es de tal tipo con “hasNext……()” con el respectivo tipo de dato.
De esta manera Java interpreta como booleano si el dato ingresado es del tipo esperado, en caso contrario retornara el mensaje que uno quisiera a modo de alerta.

In this case I was intrigued to know how to verify if the “Scanner” function can verify if a data is entered or not, apparently it must be queried if the type of data entered by the console exists and is of such type with “hasNext ……()” with the respective data type. In this way, Java interprets as a boolean if the data entered is of the expected type, otherwise it will return the message that one would like as an alert.


0
0
0.000
2 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000