-3

I want to write a small java program that asks the user for an input and checks if the input is in the array and redirects the user to a HTML page if the input is in the array.

package ticketnummercheck;
import java.util.Scanner;

public class TicketnummerCheck {

    public static void main(String[] args) {

        int ticketnummer = 0;
        Scanner input = new Scanner(System.in);
        System.out.println("Ticketnummer:");
        ticketnummer = input.nextInt();

        String [] ticketnummerDB = {"1234", "12345", "123456", "123456"};


    }

}

1 Answers1

1

Use this

if(Arrays.asList(ticketnummerDB)
         .contains(String.valueOf(ticketnummer))) {
    // contains value
}
else {
    // does not contain value
}
Mohammed Aouf Zouag
  • 17,042
  • 4
  • 41
  • 67