Basic Program I need help


/ Published in: Java
Save to your folder(s)

I need some help, i can't understand Why i can´t use it, it said me:`scanner` is never closed.
Thanks


Copy this code and paste it in your HTML
  1. package demo1;
  2. import java.util.Scanner;
  3. public class Screen2
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner scanner = new Scanner(System.in);
  8. System.out.print("Escriba su nombre: ");
  9. String nom = scanner.next();
  10. System.out.print("Escriba su edad: ");
  11. int edad = scanner.nextInt();
  12. System.out.print("Escriba su altura en m: ");
  13. double altura = scanner.nextDouble();
  14. System.out.println("Su nombre es: " + nom);
  15. System.out.println("Su edad es: " + edad);
  16. System.out.println("Su altura es de: " + altura + "m");
  17. }
  18.  
  19. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.