Concept

How do you find the length of a string and iterate over its characters?

ComputerScienceOne / String Methods

"When accessing individual characters in a string, it is necessary to know the length of the string so that we do not access invalid characters. The length() method returns an int that represents the number of characters in the string. String s = \"Hello World!\"; char last = s.charAt(s.length()-1); //last is '!' Using this method, we can easily iterate over each character in a string. for(int i=0; i<fullName.length(); i++) { System.out.printf(\"fullName[%d] = %c\n\n\", i, fullName.charAt(i)); } We can also use toCharArray and an enhanced for loop: for(char c : fullName.toCharArray()) { System.out.println(c); }"

Related Ideas

How do you find the length of a string and iterate over its characters? | ComputerScienceOne | Bifalgorithm | Bifalgorithm