Presentation is loading. Please wait.

Presentation is loading. Please wait.

String class. Method concat Create string object –> String st1, st2; Input character to string object –> st1=br.readLine(); st2= br.readLine(); Use method.

Similar presentations


Presentation on theme: "String class. Method concat Create string object –> String st1, st2; Input character to string object –> st1=br.readLine(); st2= br.readLine(); Use method."— Presentation transcript:

1 String class

2 Method concat Create string object –> String st1, st2; Input character to string object –> st1=br.readLine(); st2= br.readLine(); Use method –> st1.concat(st2);

3 Method Summary char char charAtcharAt(int index) Returns the character at the specified index. int int compareTocompareTo(Object o) Compares this String to another Object.Object int int compareTocompareTo(String anotherString) Compares two strings lexicographically.String int int compareToIgnoreCasecompareToIgnoreCase(String str) Compares two strings lexicographically, ignoring case differences.String String String concatconcat(String str) Concatenates the specified string to the end of this string.String

4 booleanboolean contentEqualscontentEquals(StringBuffer sb) Returns true if and only if this String represents the same sequence of characters as the specified StringBuffer.StringBuffer copyValueOfcopyValueOf(char[] data) Returns a String that represents the character sequence in the array specified. copyValueOfcopyValueOf(char[] data, int offset, int count) Returns a String that represents the character sequence in the array specified. endsWithendsWith(String suffix) Tests if this string ends with the specified suffix.String static Stringstatic String static Stringstatic String boolean boolean

5 boolean boolean equalsequals(Object anObject) Compares this string to the specified object.Object boolean boolean equalsIgnoreCaseequalsIgnoreCase(String anotherString) Compares this String to another String, ignoring case considerations.String byte[] byte[] getBytesgetBytes() Encodes this String into a sequence of bytes using the platform's default charset, storing the result into a new byte array. void void getBytesgetBytes(int srcBegin, int srcEnd, byte[] dst, int dstBegin) Deprecated. This method does not properly convert characters into bytes. As of JDK 1.1, the preferred way to do this is via the the getBytes() method, which uses the platform's default charset.

6 byte[]byte[] getBytesgetBytes(String charsetName) Encodes this String into a sequence of bytes using the named charset, storing the result into a new byte array.String void void getCharsgetChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) Copies characters from this string into the destination character array. int int hashCodehashCode() Returns a hash code for this string. int int indexOfindexOf(int ch) Returns the index within this string of the first occurrence of the specified character.

7 int int indexOfindexOf(int ch, int fromIndex) Returns the index within this string of the first occurrence of the specified character, starting the search at the specified index. int int indexOfindexOf(String str) Returns the index within this string of the first occurrence of the specified substring.String int int indexOfindexOf(String str, int fromIndex) Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.String String String internintern() Returns a canonical representation for the string object.

8 int int lastIndexOflastIndexOf(int ch) Returns the index within this string of the last occurrence of the specified character. int int lastIndexOflastIndexOf(int ch, int fromIndex) Returns the index within this string of the last occurrence of the specified character, searching backward starting at the specified index. int int lastIndexOflastIndexOf(String str) Returns the index within this string of the rightmost occurrence of the specified substring.String int int lastIndexOflastIndexOf(String str, int fromIndex) Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.String int int lengthlength() Returns the length of this string.

9 boolean boolean matchesmatches(String regex) Tells whether or not this string matches the given regular expression.String regular expression boolean boolean regionMatchesregionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len) Tests if two string regions are equal.String boolean boolean regionMatchesregionMatches(int toffset, String other, int ooffset, int len) Tests if two string regions are equal.String String String replacereplace(char oldChar, char newChar) Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar. String String replaceAllreplaceAll(String regex, String replacement) Replaces each substring of this string that matches the given regular expression with the given replacement.String regular expression

10 StringString replaceFirstreplaceFirst(String regex, String replacement) Replaces the first substring of this string that matches the given regular expression with the given replacement.String regular expression splitsplit(String regex) Splits this string around matches of the given regular expression.String regular expression splitsplit(String regex, int limit) Splits this string around matches of the given regular expression.String regular expression startsWithstartsWith(String prefix) Tests if this string starts with the specified prefix.String startsWithstartsWith(String prefix, int toffset) Tests if this string starts with the specified prefix beginning a specified index.String String[] String[] String[] String[] boolean boolean boolean boolean

11 CharSequenceCharSequence subSequencesubSequence(int beginIndex, int endIndex) Returns a new character sequence that is a subsequence of this sequence. substringsubstring(int beginIndex) Returns a new string that is a substring of this string. substringsubstring(int beginIndex, int endIndex) Returns a new string that is a substring of this string. toCharArraytoCharArray() Converts this string to a new character array. toLowerCasetoLowerCase() Converts all of the characters in this String to lower case using the rules of the default locale. String String String String char[] char[] String String

12 String String toLowerCasetoLowerCase(Locale locale) Converts all of the characters in this String to lower case using the rules of the given Locale.Locale String String toStringtoString() This object (which is already a string!) is itself returned. String String toUpperCasetoUpperCase() Converts all of the characters in this String to upper case using the rules of the default locale. String String toUpperCasetoUpperCase(Locale locale) Converts all of the characters in this String to upper case using the rules of the given Locale.Locale String String trimtrim() Returns a copy of the string, with leading and trailing whitespace omitted.

13 static Stringstatic String valueOfvalueOf(boolean b) Returns the string representation of the boolean argument. valueOfvalueOf(char c) Returns the string representation of the char argument. valueOfvalueOf(char[] data) Returns the string representation of the char array argument. valueOfvalueOf(char[] data, int offset, int count) Returns the string representation of a specific subarray of the char array argument. static Stringstatic String static Stringstatic String static Stringstatic String

14 static Stringstatic String valueOfvalueOf(double d) Returns the string representation of the double argument. valueOfvalueOf(float f) Returns the string representation of the float argument. valueOfvalueOf(int i) Returns the string representation of the int argument. valueOfvalueOf(long l) Returns the string representation of the long argument. valueOfvalueOf(Object obj) Returns the string representation of the Object argument.Object static Stringstatic String static Stringstatic String static Stringstatic String static Stringstatic String


Download ppt "String class. Method concat Create string object –> String st1, st2; Input character to string object –> st1=br.readLine(); st2= br.readLine(); Use method."

Similar presentations


Ads by Google