Write a Java method that accepts three integers and checks whether they are consecutive or not. Returns true or false.

Source Code:

public class ConsecutiveCheck {
public static void main(String[] args) {
boolean result = checkConsecutive(10, 11, 12);
System.out.println(result);
}

public static boolean checkConsecutive(int a, int b, int c) {
int min = Math.min(a, Math.min(b, c));
int max = Math.max(a, Math.max(b, c));
int mid = a + b + c – min – max;
return (max – mid == 1) && (mid – min == 1);
}
}

Output: