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 242 views
2 answers 143 views
143 views asked Oct 5, 2023 by avibootz
4 answers 258 views
1 answer 125 views
...