Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static String getFullName(String firstName, String lastName) { StringBuffer result = new StringBuffer(); boolean flag = false; if (lastName != null && !lastName.isEmpty()) { result.append(lastName); flag = true; } if (firstName != null && !firstName.isEmpty()) { if (flag) { result.append(", "); } result.append(firstName); } return result.toString(); } }