// Scala program to check whether// a string is empty or notobjectSample{defmain(args:Array[String]){valstr1=newStringBuilder("This is india");valstr2=newStringBuilder("");if(str1.isEmpty)println("string 'str1'
2.2、用subSequence()函数截取 在Kotlin中除了使用上面讲解到的使用subString()截取字符串外,还可以使用subSequence()函数截取。 我们看一看其源码实现: public fun subSequence(startIndex: Int, endIndex: Int): CharSequence public fun CharSequence.subSequence(range: IntRange): CharSequence = subSequence(range.s...
subSequence(0, 3).toString()); return aFloat >= 1.6; } 代码示例来源:origin: gocd/gocd boolean isVersionOnedotZeorOrHigher(String hgout) { String hgVersion = parseHgVersion(hgout); Float aFloat = NumberUtils.createFloat(hgVersion.subSequence(0, 3).toString()); return aFloat >= 1; } ...
subSequence(int start, int end) Has the same result as the substring function, but is present so that string may implement the CharSequence interface.String substring(int start) Returns a string containing a suffix of this string.String...
* {@codesrcBegin} is negative. * {@codesrcBegin} is greater than {@codesrcEnd} * {@codesrcEnd} is greater than the length of this * string * {@codedstBegin} is negative * {@codedstBegin+(srcEnd-srcBegin)} is larger than * {@codedst.length} */publicvoid...
public String[] split(String regex, int limit) { /* fastpath if the regex is a (1)one-char String and this character is not one of the RegEx's meta characters ".$|()[{^?*+\", or (2)two-char String and the first char is the backslash and the second is not...
Returns a subsequence from the start of the collection through the specified position. func prefix(upTo: Self.Index) -> Self.SubSequence Returns a subsequence from the start of the collection up to, but not including, the specified position. func prefix(while: (Self.Element) throws -> Bool)...
StringBuffer 其实提供了很多有用的方法, 以前用的多是 append, 其实还有: append(double) delete(int, int) deleteCharAt(int) replace(int, int, String) substring(int) subSequence(int, int) substring(int, int) insert(int, char[], int, int) ...
This method does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via the String constructors that take a charset name or that use the platform's default charset. String (byte[] bytes, int offset, int length, String charsetName) Constructs a new...
IndexOutOfBoundsException - If offset is negative, count is negative, or offset is greater than codePoints.length - count Since: 1.5 String @Deprecated(since="1.1") public String(byte[] ascii, int hibyte, int offset, int count) Deprecated. This method does not properly convert bytes int...