Here's a Java program that checks whether a given number consists of consecutive digits or not:
```java
import java.util.Scanner;
public class ConsecutiveNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter an integer: ");
long number = scanner.nextLong();
if (isConsecutiveNumber(number)) {
System.out.println("consecutive");
} else {
System.out.println("not consecutive");
}
scanner.close();
}
public static boolean isConsecutiveNumber(long number) {
String numStr = String.valueOf(number);
for (int i = 0; i < numStr.length() - 1; i++) {
int currentDigit = Character.getNumericValue(numStr.charAt(i));
int nextDigit = Character.getNumericValue(numStr.charAt(i + 1));
if (Math.abs(currentDigit - nextDigit) != 1) {
return false;
}
}
return true;
}
}
```
In this program, the `isConsecutiveNumber` method takes a long number as input and checks if it consists of consecutive digits. It converts the number to a string and iterates through each digit. It compares the absolute difference between each digit and its adjacent digit. If the difference is not equal to 1 for any pair of digits, the method returns `false`. If all pairs of digits have a difference of 1, the method returns `true`.
The `main` method prompts the user to enter an integer, calls the `isConsecutiveNumber` method to check if it consists of consecutive digits, and prints the appropriate message based on the result.