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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -