mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-06-13 09:34:32 +07:00
StreamApiMigration: minor fixes in FindFirst scenarios
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
String s = " hello ";
|
||||
String res = s.trim();
|
||||
if(args.length == 0) {
|
||||
for (<caret>int i = 0; i < s.length(); i++) {
|
||||
Integer x = i;
|
||||
if (s.charAt(x) == 'l') {
|
||||
res = String.valueOf(x);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println(res);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user