How do I swap two string variables in Java without using a third variable, i.e. the temp variable?
String a = \"one\" String b = \"two\" String temp = null; temp
String name = "george"; String name2 = "mark"; System.out.println(name+" "+name2); System.out.println(name.substring(name.length()) + name2 + " "+ name );
Here substring(); method returns empty string. hence , names can be appended.