import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
return Arrays.
stream(array
).
filter(x
-> x
!=null & !x.
equals("")).
toArray(String[]::new); }
{
String text
="red 1 green 3 blue"; System.
out.
println(Arrays.
toString(text.
split("red|green|blue"))); System.
out.
println(Arrays.
toString(text.
split("red|green|blue",
-1))); System.
out.
println(Arrays.
toString(cleanArray
(text.
split("red|green|blue")))); }
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyBTdHJpbmdbXSBjbGVhbkFycmF5KFN0cmluZ1tdIGFycmF5KSB7CgkgICAgcmV0dXJuIEFycmF5cy5zdHJlYW0oYXJyYXkpLmZpbHRlcih4IC0+IHghPW51bGwgJiAheC5lcXVhbHMoIiIpKS50b0FycmF5KFN0cmluZ1tdOjpuZXcpOwoJfQoKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN0cmluZyB0ZXh0PSJyZWQgMSBncmVlbiAzIGJsdWUiOwoJCVN5c3RlbS5vdXQucHJpbnRsbihBcnJheXMudG9TdHJpbmcodGV4dC5zcGxpdCgicmVkfGdyZWVufGJsdWUiKSkpOwoJCVN5c3RlbS5vdXQucHJpbnRsbihBcnJheXMudG9TdHJpbmcodGV4dC5zcGxpdCgicmVkfGdyZWVufGJsdWUiLCAtMSkpKTsKCQlTeXN0ZW0ub3V0LnByaW50bG4oQXJyYXlzLnRvU3RyaW5nKGNsZWFuQXJyYXkodGV4dC5zcGxpdCgicmVkfGdyZWVufGJsdWUiKSkpKTsKCX0KfQ==