Java 8 Stream from String

By Yashwant Chavan, Views 1197, Last updated on 06-Nov-2016

Learn how to create stream from String value in java 8.

tags java

Refer below steps.

IntStream java.lang.CharSequence.chars() method returns a stream of int (IntStream ) zero-extending the char values from this sequence.

Use forEach() method to performs an action for each element of this stream.

Java 8 Stream From String


public class Java8StreamFromString {
    public static void main(String[] args) {
        String str = "abcde";
        str.chars().forEach(n -> System.out.print((char) n));




Hi there! I am founder of and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][]