Flusso di(T t)
Flusso di(T t) restituisce uno stream sequenziale contenente un singolo elemento.
Sintassi:
static Stream of(T t)>
parametri: Questo metodo accetta un parametro obbligatorio T che è il singolo elemento nello Stream.
Valore di ritorno: Stream of(T t) restituisce uno Stream sequenziale contenente il separare elemento specificato.
Esempio :
anno mese
// Java code for Stream of(T t)> // to get a sequential Stream> // containing a single element.> > import> java.util.*;> import> java.util.stream.Stream;> > class> GFG {> > >// Driver code> >public> static> void> main(String[] args)> >{> >// Creating an Stream having single element only> >Stream stream = Stream.of(>'Geeks'>);> > >// Displaying the Stream having single element> >stream.forEach(System.out::println);> >}> }> |
>
come concatenare le stringhe in Java
>Produzione:
Geeks>
Flusso di (valori T…)
Flusso di (valori T…) restituisce un flusso ordinato sequenziale i cui elementi sono i valori specificati.
Sintassi:
static Stream of(T... values)>
parametri: Questo metodo accetta un parametro obbligatorio valori quali sono gli elementi del nuovo flusso.
Valore di ritorno : Flusso di (valori T…) restituisce un flusso ordinato sequenziale i cui elementi sono i valori specificati.
Esempio:
funzioni di stringa in Java
// Java code for Stream of(T... values)> // to get a sequential ordered stream whose> // elements are the specified values.> > import> java.util.*;> import> java.util.stream.Stream;> > class> GFG {> > >// Driver code> >public> static> void> main(String[] args)> >{> >// Creating an Stream> >Stream stream = Stream.of(>'Geeks'>,>'for'>,>'Geeks'>);> > >// Displaying the sequential ordered stream> >stream.forEach(System.out::println);> >}> }> |
>
>Produzione:
Geeks for Geeks>