Code:
package com.company;
import javax.swing.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
JOptionPane.showInputDialog(null, "Gib den Namen des Besitzers an um Zutritt zu erlangen");
String hallo1 = scanner.nextLine();
try {
if (hallo1.equals("Peter")) {
JOptionPane.showMessageDialog(null, "Genau, das ist der Besitzer");
}
}catch(Exception e){
JOptionPane.showMessageDialog(null, "Falsch, das ist nicht der Name");
}finally{
JOptionPane.showMessageDialog(null, "Versuche es später nocheinmal");
}
}
}
Code:
String hallo1 = scanner.nextLine();