On an assignment, I had a
string where I wanted to extract a character and store it in another string. It was something like:
String s = "12345" ;
String part ;
part = s.substring( 0, 1 ) ;
The above worked. Now, suppose I wish to us charAt() instead of substring()? I tried:
String s = "12345" ;
String part ;
part = s.charAt( 0 ) ;
When I compile the above, it errors at assigning a char to a string. So, how do I fix this? Is it more efficient to use charAt() and convert it to a string, or just use substring()?
thanks,
-Bryan