JAVA- how to convert letters in a string to specified number? -


Please help me write Java function to convert string to numerical value

Accept

1 = AIJQY

1 = P> 2 =

5 = EHNX

6 = oz

8 = FP

string For "stack overflow"

is the numeric value = 3 4 1 3 2 7 6 5 2 8 3 7 6 "

For example : -

Input: - string str = "stack overflow"; .... spaces

Return array = {3,4,1,3,2,7,6,5,2,8,3,7, 6};

I will add your numeric values ​​to a Hasharma

  {A = Gt; 1, I = & gt; 1, J = & gt; 1, Q = & gt; 1, Y = & gt; 1, B = & gt; 2, K = & Gt; 2, ...}  

You iterate the string, and to see each value in the map, and add it to the list You may want to overlap your character for lookup Are there.

 for  (in input four C) {Integer n = lookup (c); If (found) {result.add (n); }}  

and finally convert your list to a complete array


Comments

Popular posts from this blog

python - rpy2 import is not working -

javascript - How to get MySQL query result returned using $.ajax -

javascript - How to use the code plugin with popcornjs -