style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@ -42,10 +42,8 @@ public class LinearSearch implements SearchAlgorithm {
Random r = new Random();
int size = 200;
int maxElement = 100;
Integer[] integers = Stream
.generate(() -> r.nextInt(maxElement))
.limit(size)
.toArray(Integer[]::new);
Integer[] integers
= Stream.generate(() -> r.nextInt(maxElement)).limit(size).toArray(Integer[] ::new);
// the element that should be found
Integer shouldBeFound = integers[r.nextInt(size - 1)];
@ -53,12 +51,7 @@ public class LinearSearch implements SearchAlgorithm {
LinearSearch search = new LinearSearch();
int atIndex = search.find(integers, shouldBeFound);
System.out.printf(
"Should be found: %d. Found %d at index %d. An array length %d%n",
shouldBeFound,
integers[atIndex],
atIndex,
size
);
System.out.printf("Should be found: %d. Found %d at index %d. An array length %d%n",
shouldBeFound, integers[atIndex], atIndex, size);
}
}