Java String.trim() method usage example tutorial, this method returns a copy of the beginning and end of the string with white spaces removed or a string if it has no leading or trailing spaces.
Description
##java.lang.String.trim () method returns a copy of the string and ignores (removes) leading and trailing whitespaceThe following is the declaration of the java.lang.String.trim() method
public String trim()
包装com.yiibai;import java.lang。*;public class StringDemo { public static void main(String [] args){ //带有前导和尾随空格的字符串 String str =“This is YiiBai”; System.out.print(“Before trim =”); System.out.println(“..”+ str +“..”); //前导和尾随的空格被删除 System.out.print(“After trim =”); System.out.println(“..”+ str.trim()+“..”); }}
之前修剪= ..这是YiiBai .. 修剪= ..这是YiiBai ..
Share examples of TrimHelper methods in Java
2.Detailed explanation of usage examples of java trim
3.How to remove spaces on both sides of a string using trim() in js
4. 5.The PHP function trim() that removes leading and trailing spaces and special characters from a string
The above is the detailed content of Detailed explanation of String.trim() method examples in Java. For more information, please follow other related articles on the PHP Chinese website!