api
, , , lambdas .., .
You can use three dots ...to indicate "any number of arguments," which in your method will effectively turn intoString[] arguments
Then repeat them and compare with the custom comparison function. In this case, I decided to emulate javascript with non-zero lines, not empty lines. Change as you see fit.
public String sourceFilter(String... input) {
for(String test : input) {
if(test != null && !test.isEmpty()) {
return test;
}
}
return "";
}
I don’t know that the breakeven point is that threads are more efficient in this case, but I would suggest that it would be a fairly large number to cover the initialization cost for it.
source
share