How to create a stream from string in Java

1 Answer

0 votes
import java.util.stream.Stream;

public class MyClass 
{
    public static void main(String args[])
    {
        String str = "Java";
        
        Stream<String> stream = Stream.of(str);
        
        stream.forEach(System.out::println);
    }
}




/*
run:

Java

*/

 



answered Mar 23, 2023 by avibootz

Related questions

1 answer 306 views
2 answers 234 views
234 views asked Oct 5, 2023 by avibootz
4 answers 411 views
1 answer 188 views
...