Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 22, 2021 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/cc91d0b79e3da53a355bd052fbcffa26 to your computer and use it in GitHub Desktop.
Save parzibyte/cc91d0b79e3da53a355bd052fbcffa26 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Escribe un número entero: ");
int algunEntero = sc.nextInt();
System.out.println("El número es: " + algunEntero);
// Consumir salto de línea que dejó nextInt
sc.nextLine();
System.out.println("Ahora escribe una cadena: ");
String cadena = sc.nextLine();
System.out.println("La cadena es: " + cadena);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment