number something = 1234;
String s = something + "";
char[] chars = s.toCharArray();
I'm not sure if that will work; you may want to try it though.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
Moutanna:
My example is legal Java code. It's more robust than your example because my example makes use of Java's autoboxing features. Number being an abstract class doesn't matter because I never tried to instantiate 'Number'. The example instantiates some class in Number's inheritance hierarchy.
Number n = -2.9;
System.out.println(n.getClass());
char[] chars = (n + "").toCharArray();
for (Character c: chars) System.out.print(c);
Sammich: Mark solved threads as solved.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354