Update StringIterator.java
This commit is contained in:
parent
98c8e96fca
commit
66604b8e27
|
@ -4,14 +4,6 @@ import java.text.*;
|
|||
import java.util.*;
|
||||
|
||||
public class StringIterator {
|
||||
public static void main(String[] args) {
|
||||
String str = "Hello, Baeldung!";
|
||||
System.out.println(javaforLoop(str));
|
||||
System.out.println(java8forEach(str));
|
||||
System.out.println(javaCharArray(str));
|
||||
System.out.println(javaRegexExp(str));
|
||||
System.out.println(javaCharacterIterator(str));
|
||||
}
|
||||
|
||||
public static String javaCharArray(String str){
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
@ -38,15 +30,6 @@ public class StringIterator {
|
|||
return result.toString();
|
||||
}
|
||||
|
||||
public static String javaRegexExp(String str){
|
||||
StringBuilder result = new StringBuilder();
|
||||
String[] characters = str.split("");
|
||||
for (String c : characters) {
|
||||
result.append(c);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String javaCharacterIterator(String str){
|
||||
StringBuilder result = new StringBuilder();
|
||||
CharacterIterator it = new StringCharacterIterator(str);
|
||||
|
|
Loading…
Reference in New Issue