/*********************** * @author gtowell * @ * Purpose: * String sample * Created: August 28, 2019 * Modified: August 29, 2019 * January 9, 2020 ***********************/ public class Stringer { public static void main(String[] args) { String geoffrey = "Geoffrey"; String geoffrey2 = new String("Geoffrey"); System.out.println(geoffrey); String geoff = geoffrey.substring(0, 5); System.out.println(geoff); String c = geoffrey.concat(geoff); String d = geoffrey + geoff; // + on strings does concatenation System.out.println("|" + geoffrey + "|" + geoff + "|" + c + "|"); System.out.println("|" + geoffrey + "|" + geoff + "|" + d + "|"); if (geoffrey == geoffrey2) { // the geoffrey and geoffrey2 objects are not the same so this is not printed System.out.println("Same object |" + geoffrey + "||" + geoffrey2 + "|"); } if (geoffrey.equals(geoffrey2)) { System.out.println("Same String ||" + geoffrey + "||" + geoffrey2 + "|"); } } }