loops - How to store string increments as a concatenated String? -
scanner input = new scanner(system.in); string userinput = input.nextline(); string letterarray[] = new string[userinput.length()]; for(int = 0; < userinput.length(); i++ ){ letterarray[i] = userinput.substring(i, i+1); } for(int j = userinput.length()-1; j>=0; j--){ system.out.print(letterarray[j]); }
i have stored users input want reverse have inputted , store reversed form string.
i have managed display string superposition of each letter increment has been stored in array, how go storing reversed form string?
if want print reverse can that:
scanner input = new scanner(system.in); string userinput = input.nextline(); for(int i=1;i<=userinput.length();i++){ system.out.print(userinput.charat(userinput.length()-i)); }
other if wanto turn string array can use simpler methods like: string[] letterarray = userinput .split("");
if want store array or new string can this:
scanner input = new scanner(system.in);
string userinput = input.nextline(); char[] characters=new char[userinput.length]; for(int i=1;i<=userinput.length();i++){ characters[i-1]=userinput.charat(userinput.length()-i); system.out.print(characters[i-1]); } string newstring=new string(characters);
there many possibilities.