Skip to content

Instantly share code, notes, and snippets.

@behrends
Created November 29, 2017 13:55
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 behrends/cdf1921cd362e2d0af5ddd10f800b026 to your computer and use it in GitHub Desktop.
Save behrends/cdf1921cd362e2d0af5ddd10f800b026 to your computer and use it in GitHub Desktop.
Eingabe in Java mit Scanner
import java.util.Scanner;
public class Eingabe {
public static void main(String[] args) {
int number = 8;
String text = "Text";
Scanner scanner = new Scanner(System.in);
// Eingabe
System.out.print("Zahl eingeben: ");
// number <---- zahl eingelesen
number = scanner.nextInt();
System.out.println();
System.out.print("Text eingeben: ");
text = scanner.next();
// Berechnung
// Ausgabe des Ergebnis
System.out.print("Die Zahl lautet: " + number);
System.out.println();
System.out.print("Der Text lautet: " + text);
scanner.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment