A simple way to think about it is to display an extra space if a number is less than 10. This will not work if dealing with negative numbers or numbers greater than 99. That adds complexity to this method.
Research printf operation in Java. This is a more comprehensive way and can be used to do lot's of different formatting.