class SomeClass {
public List<Integer> calculate() {
List<Integer> results = new ArrayList<>();
//Выполняем вычисления, заполняем коллекцию
return Collections.sort(results);
}
...
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
System.out.format("%s=%s%n", envName, env.get(envName));
}
JAVA_HOME=/usr/lib/jvm/java-8-oracle
XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg
XFILESEARCHPATH=/usr/dt/app-defaults/%L/Dt
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
GNOME_KEYRING_CONTROL=
LANG=ru_RU.UTF-8
XDG_SESSION_TYPE=x11
XDG_SESSION_ID=c1
DISPLAY=:0
GDM_LANG=ru_RU
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/quadra
UPSTART_EVENTS=xsession started
SESSION=ubuntu
DESKTOP_SESSION=ubuntu
GPG_AGENT_INFO=/run/user/1000/keyring/gpg:0:1
...
List<String> list = ...
list.stream()
.filter(YourPredicates::somePredicate)
.forEach(System.out::println);