/**
* Title : Demo string concat
* Deskripsi: Membuat string yang baru dari string asli dengan method concat
*/
public class DemoStringConcat {
/** Main method */
public static void main(String args[])
{
String str1 = new String("Selamat"),
str2 = new String("Pagi"),
str3 = new String("Indonesia"),
strBaru1, strBaru2;
System.out.println("\nPROGRAM DEMO STRING CONCATENATION");
System.out.println("-----------------------------------\n");
strBaru1 = str1.concat(str2);
strBaru2 = str1.concat(str2).concat(str3);
System.out.println("String str1 : " + str1);
System.out.println("String str2 : " + str2);
System.out.println("String str3 : " + str3);
System.out.println("\nHasil dari str1.concat(str2) : " + strBaru1);
System.out.println("\nHasil dari str1.concat(str2).concat(str3)" + " : " +strBaru2);
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment