In Java, what is the best way to get each individual digit of an integer and its position for comparison?
<p>New to programming: In Java, what is the best way to get each individual digit of an Integer and its position for comparisons? For example, with an input of an Integer i = 12345, I'd like to preform a comparison operation on each individual digit 1, 2, 3, 4, and 5. Since I can't get the index of the integer, I converted the integer to string, iterated, and used charAt().</p>

<pre><code>String sI = Integer.toString(i);
for(int j = 0; j&lt;i; j++){
    if(charAt(j)&gt;n){
    //do something
    }
}
</code></pre>