StreamApiMigration: minor fixes in FindFirst scenarios

This commit is contained in:
Tagir Valeev
2017-01-18 13:50:46 +07:00
parent 4c07a74eb5
commit cbd273dda8
3 changed files with 52 additions and 20 deletions
@@ -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);
}
}
@@ -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);
}
}