i have string arraylist contents [a, b, c, d, e...] , forth. however, need have character based arraylist (arraylist name). how go upon looping through string arraylist , converting elements char, append char arraylist?
the same goes converting string arraylist full of numbers [1,2,3,4...] integer arraylist. how go upon looping through, converting type, , adding new arraylist?
for first problem loop using , use char charat(0)
method of string
list<string> arraylist; list<character> newarraylist = new arraylist<>(); for( int = 0; < arraylist.size(); i++ ){ string string = arraylist.at(i); newarraylist.add( string.charat(0) ); // 0 becouse each string have 1 char }
for second can use intenger.parseint
list<string> arraylist; list<int> newarraylist = new arraylist<>(); for( int = 0; < arraylist.size(); i++ ) { string string = arraylist.at(i); newarraylist.add( intenget.parseint(string) ); }