Scanner scan = new Scanner(System.in);
System.out.println("Please enter a number with 4 digits: ");
while(!scan.hasNextInt()){
//If the next int is not an integer, it will allow you to input again until an int is recieved
scan.next();
}
int n = scan.nextInt();
String strn = "" + n;
The issue I'm having is that when a user inputs a code with a zero as the first number, such as 0481, it's saved in the string as 481. How would I make sure a leading zero is counted in this case?