提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
如何从字符串中删除前导和尾随空格
/**来 自 N o w J a v a . c o m**/ public class Main { public static void main(String[] args) { String str = " String Trim Example "; String strTrimmed = str.trim(); System.out.println("Original String is: " + str); System.out.println("Removed Leading and trailing space"); System.out.println("New String is: " + strTrimmed); } }