How in Java do you return the first digit of an integer.?
i.e.
345
Returns an int of 3.
Here is a smaller version to get digits of all positions, it works with negative value (not decimal).
int number = -23456;
int length = (int) Math.log10(Math.abs(number)) + 1; //This gets the length of the number of digits used
//Math.abs to change negative int to positive
System.out.println("Digit at pos " + 1 + " is :- " + (int)(Math.abs(number)/Math.pow(10,(length-1))));
for (int i = 2; i <= length; i++){
System.out.println("Digit at pos " + i + " is :- " + (int)(Math.abs(number)/Math.pow(10,(length-i))%10));
}