Java String.trim()会删除多少个空格? [英] How many spaces will Java String.trim() remove?
本文介绍了Java String.trim()会删除多少个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java中,我有一个这样的字符串:
In Java, I have a String like this:
" content ".
将 String.trim()
全部删除这些边上的空格或每个边上只有一个空格?
Will String.trim()
remove all spaces on these sides or just one space on each?
推荐答案
所有这些。
返回:
删除前导和尾随空格的此字符串的副本,如果没有前导或尾随空格,则为此字符串。
Returns: A copy of this string with leading and trailing white space removed, or this string if it has no leading or trailing white space.
〜引自Java 1.5.0 docs
~ Quoted from Java 1.5.0 docs
(但你为什么不试试看自己呢?)
这篇关于Java String.trim()会删除多少个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文