void (String[] args) { String s = " hello "; String res = s.trim(); if(args.length == 0) { res = IntStream.range(0, s.length()).boxed().filter(x -> s.charAt(x) == 'l').findFirst().map(String::valueOf).orElse(res); } System.out.println(res); }