mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 14:25:04 +07:00
StreamApiMigration: collect(joining()): allow separator addition based on counting loop variable value
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
String sb = list.stream().limit(10).collect(Collectors.joining(","));
|
||||
System.out.println(sb);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public void test(List<String> list) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int <caret>i=0; i<Math.min(10, list.size()); i++) {
|
||||
if(i > 0) sb.append(",");
|
||||
sb.append(list.get(i));
|
||||
}
|
||||
System.out.println(sb.toString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user