Java將二個字符串合並成一個字符串


Java當中"abc"+"de"="abcde" ,類似c語言中的strcat函數。

輸入

abc
de

 輸出效果

 

 

package com;
import java.io.*;
public class strcat {
    public static void main(String[] args)throws IOException
    {
        String str1,str2,str3;
        BufferedReader buf;
        buf=new BufferedReader (new InputStreamReader(System.in));
        System.out.println("輸入第一個字符串:");
        str1=buf.readLine();
        System.out.println("輸入第二個字符串:");
        str2=buf.readLine();
        str3=str1+str2;
        System.out.println("輸出二個字符串的str1|str2拼接版:"+str1+str2);
        System.out.println("輸出二個字符串的str3:"+str3);
    }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM