2013年9月5日 星期四

String - concat()

String 類別 (class) 有 concat() 方法 (method) ,將 str 接到字串的後面。
public class Test {
 public static void main(String[] args){
  String x1 = "xyz";
  String x2 = "abc";
  
  System.out.println(x1+x2);
  x1 = "tuv";
  System.out.println(x1);
  x2 = "def";
  System.out.println(x2);
  x2 = x2.concat("def");
  System.out.println(x2);
  
 }
}

沒有留言:

張貼留言