Thursday, December 16, 2010

Sample code using method String "concat"

package com.andia.cm.parser.siemens.sccp.tables;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class TestClas {
    public static void main(String[] args) throws IOException {

        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter First String:");
        String str1 = bf.readLine();
        System.out.println("Enter Second String:");
        String str2 = bf.readLine();
        System.out.println("Combin string example!");

        // penggunaan concat sama dengan String yang dibawah
        String com = str1.concat(str2);
        System.out.println("Combined string: " + com);
        // Variable dendy sama dengan String com diatas
        String dendy = str1 + str2;
        System.out.println(dendy);

    }
}

No comments: