目录

String trim()

描述 (Description)

此方法返回字符串的副本,省略前导和尾随空格。

语法 (Syntax)

以下是此方法的语法 -

public String trim()

参数 (Parameters)

这是参数的细节 -

  • NA

返回值 (Return Value)

  • 它返回此字符串的副本,其中删除了前导和尾随空格,如果没有前导或尾随空格,则返回此字符串。

例子 (Example)

import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str = new String("   Welcome to iowiki.com   ");
      System.out.print("Return Value :" );
      System.out.println(Str.trim() );
   }
}

这将产生以下结果 -

输出 (Output)

Return Value :Welcome to iowiki.com
↑回到顶部↑
WIKI教程 @2018