<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                > StringJoiner是java.util包中的一個類,用于構造一個由分隔符分隔的字符序列(可選),并且可以從提供的前綴開始并以提供的后綴結尾。 # 1. 分隔符和前后綴 ~~~ public class StringJoinerTest { public static void main(String[] args) { //分隔符 StringJoiner sj = new StringJoiner("-"); sj.add("hello"); sj.add("world"); sj.add("tuna"); System.out.println(sj.toString()); //前后綴加分隔符 StringJoiner sj1 = new StringJoiner("~","[","]"); sj1.add("welcome").add("to").add("changchun"); System.out.println(sj1.toString()); } } ~~~ 結果 ``` hello-world-tuna [welcome~to~changchun] ``` # 2. 在stream中使用 例子將list用逗號分隔 ~~~ public class StringJoinTest { public static void main(String[] args) { List<String> list = Arrays.asList("hello", "world", "tuna"); //stream + stringbuilder String s1 = list.stream().reduce(new StringBuilder(), (sb, s) -> sb.append(s).append(','), StringBuilder::append).toString(); System.out.println(s1); //里面用的StringJoiner String collect = list.stream().collect(Collectors.joining(",")); System.out.println("java8:" + collect); } } ~~~ 輸出: ``` hello,world,tuna, java8:hello,world,tuna ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看