java - Getting ints array instead of characters array -
i trying code problem convert double string , insert array. tried various methods these don't give expected output.
public int[] makepi() { double pi = math.pi; string spi = string.valueof(pi); int[] arr = new int[3]; for(int =0; i<3; i++) { arr[i] = spi.charat(i); } return arr; }
output should array first 3 characters of pi below :-
[ 3, 1, 4 ]
while getting [51, 46, 49]
i handle decimal character if needed.
just hint needed.
please don't provide full program spoiler. :-)
look @ ascii table. see corresponding chars integers you're getting? should hint you.
note you're assigning result int
array, while you're running on characters.
Comments
Post a Comment