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

Popular posts from this blog

javascript - Feed FileReader from server side files -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -