java - How do I create a number of chars that are automatically given a name based on a int? -


i'm creating program , needs way convert each letter of string char. number of letters in string variable, i'm using

s.length() 

to create int has number of chars need make. question how extract letters each point in string , input them chars automatically named? e.g.

char 0 = s.charat(0) char 1 = s.charat(1) etc... 

you can't thing you've done in example. you'll have hand or make kind of list, example arraylist. if so, loop , check if it's bigger int i , add value list. other (and easier) way use string.tochararray , able chararray[char number] then.

example:

string s = "wesley luh"; char[] ca = s.tochararray(); system.out.println("" + ca[0] + ca[1] + ca[2]); // result in wes 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -