diff --git a/core-java-modules/core-java-strings/src/main/java/com/baeldung/stringIterator/StringIterator.java b/core-java-modules/core-java-strings/src/main/java/com/baeldung/stringIterator/StringIterator.java new file mode 100644 index 0000000000..2ffabc48d4 --- /dev/null +++ b/core-java-modules/core-java-strings/src/main/java/com/baeldung/stringIterator/StringIterator.java @@ -0,0 +1,14 @@ +package com.baeldung.stringIterator; + +public class StringIterator { + public static void main(String[] args) { + String str = "Hello, Baeldung!"; + java8forEach(str); + } + + public static void java8forEach(String str){ + str.chars().forEach(name -> { + System.out.print((char) name); + }); + } +}