IntStream of() 方法在 Java 中
Java 中的 IntStream of() 方法提供以下兩種形式
IntStream of(int t) 方法
以下 of() 方法返回一個包含一個元素的順序 IntStream。以下是語法
static IntStream of(int t)
在此,引數 t 是唯一元素。
IntStream of(int… values) 方法
以下 of() 方法返回一個順序排列的流,其元素是指定的值
static IntStream of(int… values)
在此,引數 values 是新流的元素。
以下是一個在 Java 中實現 IntStream of() 方法的示例
示例
import java.util.*;
import java.util.stream.IntStream;
public class Demo {
public static void main(String[] args) {
IntStream intStream = IntStream.of(10, 20, 30, 40, 50);
intStream.forEach(System.out::println);
}
}輸出
10 20 30 40 50
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP