Check out example codes for "java loop through string". It will help you in understanding the concepts better.

Code Example 1

String s = "...stuff...";

for (int i = 0; i < s.length(); i++){
    char c = s.charAt(i);        
    //Process char
}

Code Example 2

String scientistName = "Isaac Newton";
 
for (int i = 0; i < scientistName.length(); i++) {
    System.out.print(scientistName.charAt(i) + " "); // I s a a c   N e w t o n
}

//*********************************************************
// you can cast a string into a char[]
String str = "strings are not primitive types!";
 

for (char ch : str.toCharArray()) {
    	System.out.print(scientistName.charAt(i) + " ");
    }
}

Learn ReactJs, React Native from akashmittal.com