parse string in char format into an array list java -



parse string in char format into an array list java -

say instance have string ie

"my dog did foo"

i want pass each character array list , perform operations according indexes.

so need convert characters decimal values in case :-

"my dog did foo"

would translate next decimal representation:-

109 121 32 100 111 103 32 100 105 100 32 97 32 70 111 111

once done need send array list , compile string using sec number "121"

the lastly number "111" , lets "97" , doing calculations numbers.

so if these parsed arraylist index sec number in case "121" index1, index "111" in case index equal strings length.(the lastly char) means need determine index before. , 97 index 11.

how can write statement convert string decimal char values, add together each char own index in array list , calculations based on indexes? been killing me on month!

the next code terribly wrong illustrates intend do

if utilize "i." signify index in array.

k = 0; private string lengthofstring = k; while (k <= lengthofstring){ system.out.println(i.1+i.11 + "-" + i.lengthofstring); k++ }

supposedly printing :-

218-111(or whichever @ index equal lengthofstring)

any help amazing

many in advance help u can offer.

having:

string inputstring = "my dog did foo";

1. convert string array of chars:

in case, maybe arraylist not best option. utilize char array:

char[] allstringchars;

the string class provides method that, or can loop next algorithm:

declare allstringchars inputstring size declare 0 each char on inputstring re-create char @ inputstring[i] allstringchars[i] increment end

to specific char inputstring, utilize inputstring.chatat(i) method.

2. operations on values:

after covert inputstring array of characters, can obtain integer value of character:

int firstvalue = allstringchars[0]; int lastvalue = allstringchars[allstringchars.length - 1];

hope helps.

java arrays string arraylist char

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -