Question:
How do you append a string with another string?
Code:
public class AppendString { public static void main(String[] args) { String str1 = "I like java"; String str2 = "I like pizza"; System.out.println("str1: " + str1); System.out.println("str2: " + str2); String str3 = str1 + " and " + str2; System.out.println("str3: " + str3); } }
Output:
$ java AppendString str1: I like java str2: I like pizza str3: I like java and I like pizza