Looking at the code supplied it seems a tad over complicating the whole thing, here is a simple solution...
int number = 4085;
int firstDigit = number;
while (firstDigit > 9)
{
firstDigit = firstDigit / 10;
}
System.out.println("The First Digit is " + firstDigit);