I want to split my int value into digits. eg if the no. is 542, the result should be 5,4,2.
I have 2 options. 1) Convert int into String & then by using getCharA
Use the mod 10 rule...
List<Integer> digits = new ArrayList<Integer>(); while (n > 0) { digits.add(n%10); n/=10; }
List<Integer> digits(int i) { List<Integer> digits = new ArrayList<Integer>(); while(i > 0) { digits.add(i % 10); i /= 10; } return digits; }