Day3 String
Day3 String
WWW.PAVANONLINETRAININGS.COM
Strings
▪ length(): It returns count of total number of characters present in the String.
▪ concat() : Combines a specific string at the end of another string and ultimately returns a combined
string. It is like appending another string.
String s=“Welcome”
s.concat(s1) Welcome To Java
String s1=“ To Java”
▪ trim() : The java string trim() method removes the leading and trailing spaces.
WWW.PAVANONLINETRAININGS.COM
Strings
▪ charAt(): Returns a char value at the given index number. The index number starts from 0.
▪ contains() : Searches the sequence of characters in this string. It returns true if sequence of char values are found
in this string otherwise returns false.
▪ equals() : Compares the two given strings based on the content of the string. If any character is not matched, it
returns false. If all characters are matched, it returns true.
WWW.PAVANONLINETRAININGS.COM
Strings
▪ equalsIgnoreCase() : Compares two string on the basis of content but it does not check the case like
equals() method. In this method, if the characters match, it returns true else false.
▪ replace(): Returns a string, replacing all the old characters or CharSequence to new characters. There
are 2 ways to replace methods.
WWW.PAVANONLINETRAININGS.COM
StringsStrings
▪ Substring() : Returns substring of a string based on starting index and ending index.
Starting Index 0 1 2 3 4 5 6
s W E L C O M E
Ending Index
1 2 3 4 5 6 7
WWW.PAVANONLINETRAININGS.COM
StringsStrings
▪ toLowerCase(): returns the string in lowercase letter.
WWW.PAVANONLINETRAININGS.COM
Assignment (Strings)
WWW.PAVANONLINETRAININGS.COM