9:21 am - Thursday February 23, 2017

Java String Example Programs

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044


1.Compare equality of two string value boolean equals(Object anObject)

2.Compare equality of two string Ignoring case boolean equalsIgnoreCase(String anotherString)

3.Encode given string to byte array byte[ ] getBytes[ ]

4.Get HashCode of a given string int hashcode( )

5.Retrieve index position of given character int indexOf(int ch)

6.Retrieve index position of a char from specified index int indexOf(int ch, int fromIndex)

7.Retrieves the index position of given string int indexOf(String str)

8.String object in String pool String intern( )

9.Check whether a given string is empty boolean isEmpty()

10.Search a position of a character from the last int lastIndexOf(int ch)

11.Search index of a character from given position lastIndexOf(int ch,int fromIndex)

12.Find the length of the string int length()

13.Check whether a given regex matches in a string boolean matches(String regex)

14.lReplace a character with new character String replace(char oldChar,char newChar)

15.Replace all String matches the given regex String replaceAll(String regex, String replacement)

16.Replace first occurrence of a string for given regex String replaceFirst(String regex, String replacement)

17.Retrieve the character at given position char charAt( int index)

18.Compare two string in dictionary order int compareTo(String anotherStr)

19.Compare two string in dictionary order (without case) int compareToIgnoreCase(string str)

20.Concatenate two string String concat(String str)

21.Check whether the given char sequence is found in the string boolean contains(CharSequence s)

22.Check whether the given char sequence is equal to string boolean contentEquals(CharSequence cs)

23.Check suffix of the string boolean endswith(string suffix)


Filed in: Java Examples

Comments are closed.