What does a question mark mean in Java?

Questions mark is part of the ternary operator ?:, that is a different version of the if statement

You can use the ternary operator to select a value by some condition:

java.util.List<Integer> list = java.util.List.of(1, 2, 3);
String result = list.contains(2) ? "Two is in the list" : "Two is not in the list";

System.out.println(result); // Two is in the list