Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
collectors and stream
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; import java.util.stream.*; class Rextester { public static void main(String args[]) { int a=0; List<String> number = Arrays.asList("Hello","Chalo","Bolo","galo","Hello"); System.out.println(number.stream().map(x -> x+"a").collect(Collectors.toList())); System.out.println( number.stream().map( num->num+" Yes" ).collect( Collectors.toList() ) ); System.out.println( number.stream().sorted().collect(Collectors.toList()) ); System.out.println( number.stream().filter( num->{ if(num.startsWith("H")) System.out.print(a); else System.out.print("0"); return num.startsWith("H");}).collect(Collectors.toList() )); System.out.println( number.stream().map(i->i+i).collect(Collectors.toList())); } }
run
|
edit
|
history
|
help
0
Remove unbalanced parentheses in a given expression
classwork
[JAVA] Cool thing about iterating a map with iterator.
Tree_inorder_recursive
Path finding given 2D array
else if statement
Bubble Sort Java
Game developer
Largest prime factor
Fibonacci 2