Java tutorial
//package com.java2s; public class Main { public static String getFIO(String f, String i, String o) { String res = ""; for (String t : new String[] { f, i, o }) { if (t != null && !(t = t.trim()).isEmpty()) { res += (res.isEmpty() ? "" : " ") + t; } } return res; } }