zoukankan      html  css  js  c++  java
  • java中如何将字符串数组转换成字符串

    如果是 “字符串数组” 转 “字符串”,只能通过循环,没有其它方法 
    String[] str = {"abc", "bcd", "def"};
    StringBuffer sb = new StringBuffer();
    for(int i = 0; i < str.length; i++){
     sb. append(str[i]);
    }
    String s = sb.toString();
    
    如果是 “字符数组” 转 “字符串” 可以通过下边的方法 
    char[]   data={'a','b','c'};   
    String  s=new   String(data);
    String[] str = {"abc", "bcd", "def"};
    StringBuffer sb = new StringBuffer();
    for(int i = 0; i < str.length; i++){
     sb. append(str[i]);
    }
    String s = sb.toString();
    
    如果是 “字符数组” 转 “字符串” 可以通过下边的方法 
    char[]   data={'a','b','c'};   
    String  s=new   String(data);
  • 相关阅读:
    bzoj3224
    [洛谷日报第62期]Splay简易教程 (转载)
    bzoj1588
    codeforces467C
    codeforces616B
    codeforces379C
    codeforces545C
    codeforces285C
    codeforces659C
    快读代码level.2
  • 原文地址:https://www.cnblogs.com/pigdata/p/10305645.html
Copyright © 2011-2022 走看看