Input in JAVA | Using Scanner Class

Publié le: 28 juillet 2021
sur la chaîne: AKD Classes
52
8

#java #scanner

The Scanner class is mainly used to get the user input, and it belongs to the java.util package. In order to use the Scanner class, one need to create an object of the class and use any of the Scanner class methods.

Method Description
nextBoolean() Reads a boolean value from the user
nextByte() Reads a byte value from the user
nextDouble() Reads a double value from the user
nextFloat() Reads a float value from the user
nextInt() Reads a int value from the user
nextLine() Reads a String value from the user
nextLong() Reads a long value from the user
nextShort() Reads a short value from the user

If user enter wrong input (e.g. text in a numerical input), user will get an exception/error message (like "InputMismatchException").


Sur cette page du site, vous pouvez voir la vidéo en ligne Input in JAVA | Using Scanner Class durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur AKD Classes 28 juillet 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 52 fois et il a aimé 8 téléspectateurs. Bon visionnage!