I have a String for example: "Adam" and I would split a String into an array of single character Strings.("a","d","a","m")
your suggestion?
I have a String for example: "Adam" and I would split a String into an array of single character Strings.("a","d","a","m")
your suggestion?
String string = "Adam";
String[] splitString = string.split(""); // Split string by each char
for (String character : splitString) {
System.out.println(character); // You can initiate object TextView here and add it to separate list
}
From documentation:
public String[] split(String regex)
Splits this string around matches of the given regular expression.
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
The string "boo:and:foo", for example, yields the following results with these expressions:
Regex Result : { "boo", "and", "foo" } o { "b", "", ":and:f" }
Parameters: regex - the delimiting regular expression Returns: the array of strings computed by splitting this string around matches of the given regular expression
String str = "Adam";
TextView[] textViews = new TextView[4];
textViews[0] = textView1;
textViews[1] = textView2;
textViews[2] = textView3;
textViews[3] = textView4;
for(int i=0; i<str.length(); i++) {
textViews[i] = str.charAt(i);
}