![]() ![]() Static String join(CharSequence delimiter, Iterable elements) // (JDK 8) // Text Processing and Regular Expression (JDK 4) Static String join(CharSequence delimiter, CharSequence. Void getChars(int srcBegin, int srcEnd, char dst, int dstBegin) // copy into dst char // Working with CharSequence (super-interface of String, StringBuffer, StringBuilder)īoolean contains(CharSequence cs) // (JDK 5)īoolean contentEquals(CharSequence cs) // (JDK 5)īoolean contentEquals(StringBuffer sb) // (JDK 4) String indent(int n) // adjusts the indentation by n (JDK 12)Ĭhar toCharArray() // create a char from this string String strip() // strips the leading and trailing white spaces (Unicode aware) (JDK 11) String trim() // creates a new String removing white spaces from front and back String concat(String another) // same as str+another Creating a new String or char from the original - Strings are immutable Extracting a char or substring, include fromIdx but exclude toIdx ![]() Int lastIndexOf(String key, int fromIdx) // search backward starting at fromIdx Int indexOf(int char, int fromIdx) // search forward starting at fromIdx Searching: index from 0 to str.length()-1 Int compareTo(String another) // return 0 if this string is the same as another īoolean startsWith(String another, int fromIdx) // search begins at fromIdx Int length() // returns the length of the Stringīoolean isEmpty() // same as str.length() = 0īoolean isBlank() // contains only white spaces (Unicode aware) (JDK 11) // Comparisonīoolean equals(String another) // CANNOT use '=' or '!=' to compare two Strings in Java Refer to the JDK API for a complete listing. The commonly-used method in the String class are summarized below. For example, the method toUpperCase() constructs and returns a new String instead of modifying the existing content. That is, its content cannot be modified once it is created. '+' does not work on any other objects such as Point and Circle. ![]() The '+' operator is overloaded to concatenate two String operands.You can assign a string literal directly into a String variable, instead of calling the constructor to create a String instance. String is associated with string literal in the form of double-quoted texts such as " hello, world".Unlike C/C++, where string is simply an array of char, A Java String is an object of the class. A Java String contains an immutable sequence of Unicode characters. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |