<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # Java 程序:從字符串中刪除所有空格 > 原文: [https://www.programiz.com/java-programming/examples/remove-whitespaces](https://www.programiz.com/java-programming/examples/remove-whitespaces) #### 在此程序中,您將學習如何使用 Java 中的正則表達式刪除給定字符串中的所有空格。 ## 示例:刪除所有空格的程序 ```java public class Whitespaces { public static void main(String[] args) { String sentence = "T his is b ett er."; System.out.println("Original sentence: " + sentence); sentence = sentence.replaceAll("\\s", ""); System.out.println("After replacement: " + sentence); } } ``` 運行該程序時,輸出為: ```java Original sentence: T his is b ett er. After replacement: Thisisbetter. ``` 在上面的程序中,我們使用`String`的`replaceAll()`方法刪除并替換字符串`sentence`中的所有空格。 我們使用正則表達式`\\s`查找字符串中的所有空白字符(制表符,空格,換行符等)。 然后,將其替換為`""`(空字符串字面值)。
                  <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>

                              哎呀哎呀视频在线观看