Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/streamToLoop/afterArraySkipDistinctCount.java
Tagir Valeev 7e1064ea3c [java-intentions] More preview tests; minor fixes
GitOrigin-RevId: 22a46c15d8900d8a31514846755a013f6a67ad42
2022-07-29 17:55:13 +00:00

27 lines
623 B
Java

// "Replace Stream API chain with loop" "true-preview"
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class Main {
private static long test() {
long count = 0L;
Set<Integer> uniqueValues = new HashSet<>();
boolean first = true;
for (Integer integer : new Integer[]{1, 2, 3, 2, 3}) {
if (first) {
first = false;
continue;
}
if (uniqueValues.add(integer)) {
count++;
}
}
return count;
}
public static void main(String[] args) {
System.out.println(test());
}
}