App下載
首頁javastream_convertJava Stream - 如何將Array轉(zhuǎn)換為Stream

Java Stream - 如何將Array轉(zhuǎn)換為Stream

我們想知道如何將Array轉(zhuǎn)換為Stream。
import java.util.Arrays;
import java.util.stream.Stream;

public class Main {
  public static void main(String[] argv) {
    Stream.of("This", "is", "Java8", "Stream").forEach(System.out::println);

    String[] stringArray = new String[]{"Streams", "can", "be", "created", "from", "arrays"};
    Arrays.stream(stringArray).forEach(System.out::println);
  }
}