For example, I have a string
"My dog made a fu "/ Code> I want to pass each character in an array list and then want to execute the work according to some indexes.
So I have to convert their decimal values into letters in this case: -
"My dog has done one foo"
< P> will translate into the following decimal representation: - 109 121 32 100 111 103 32 100 105 100 32 97 32 70 111 111
I have to send it to an array list and the second number must be compiled by using the string "121"
The last number is "111" and the other says "97" and calculates with those digits A It's been raining.
So if the index is parsed for the second number in this array list, in this case "121" index is 1, in this case the index of "111" will be an index equal to the length of the string (the last four ) Which means that we need to determine this index first. And in the end 97 which index 11 will be.
How can I write a statement that will convert the string into a decimal character value, add each character to the array list in your list, and then calculate on the basis of calculations? It's killing me for more than a month!
The following code is very wrong but hopefully what I intend to do
If we "i." To point to an indicator in the array you use.
k = 0; Private string lengthoffstring = K; While (k & lt; = lengthofstring) {System.out.println (i.1 + i.11 + "-" + i.lengthofstring); K ++}
It is believed that printing: -
218-111 (or whatever is equivalent to the index length)
>
having:
string input string = "my dog made a fu";
To convert 1 string as an array:
In your case, maybe someone ArrayList
is not the best option you can use just a four array:
four [] allStringChars; The string
class already provides a method for it, or you can do something like this with the loop, like the following algorithm:
< Declare allStringChars with pre- inputstring size I copy the input string as 0 for each input strings [i] to increase allStringChars [i] I
< P> To get a special character from input string, use the inputString.chatAt (i)
method Please. 2. Work on values:
After secreting the input string
for an array of letters, you can get an integer value of any character: < / P>
int firstValue = allStringChars [0]; Int lastValue = All String Chars [allStringChars.length - 1];
Hope it helps.
Comments
Post a Comment