mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-29 08:20:55 +07:00
15 lines
414 B
Java
15 lines
414 B
Java
// "Collapse loop with stream 'findFirst()'" "true-preview"
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
public class Test {
|
|
public static void main(String[] args) {
|
|
String s = " hello ";
|
|
String res = s.trim();
|
|
if(args.length == 0) {
|
|
res = IntStream.range(0, s.length()).boxed().filter(x -> s.charAt(x) == 'l').findFirst().map(String::valueOf).orElse(res);
|
|
}
|
|
System.out.println(res);
|
|
}
|
|
}
|