0% found this document useful (0 votes)
11 views

String_class_methods_in_java_by_deepak_smart_programming_lyst9487

Uploaded by

Aakash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

String_class_methods_in_java_by_deepak_smart_programming_lyst9487

Uploaded by

Aakash Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Smart Programming : Channel

An investment in Knowledge pays the best interest….

String class methods in Java


Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

=> String class Methods :-

 Validating User Input


 length() - It provides the int value i.e. no of
characters in the String
 isEmpty() - Checks wether string is empty or not,
if empty it will return true else false
 trim() - It is used to remove the front or back side
spaces

 Comparing two strings :-


 equals() - it compares the 2 strings and retruns
the boolean value
 equalsIgnoreCase() - it compares the 2 strings
but ignores the uppercase and lowercase
 compareTo() - It compares the 2 strings
lexicographically
 compareToIgnoreCase()

1
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

 Contination of two strings :-


 '+' operator
 concat() - It concats the 2 strings

 Get sub-string from String :-


 subString() - It will return the sub string
according to the provided starting and ending
index positions
 subSequence() - It will return the CharSequence
according to the provided starting and ending
index positions

 Replacing or Removing characters :-


 replace() - It will replace the string according to
provided another string
 replaceFirst() - It will replace the first string
 replaceAll() - it will replace all the strings

2
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

 Searching characters in string :-


 indexOf() - It will retrun the index position of
provided character
 lastIndexOf() - It will retrun the index position of
provided character from last position
 contains() - It will return boolean value, true if
string present else false
 charAt() - It will return the index position of
provided character
 endsWith() - It will return boolean value if string
is matched from ending
 startsWith()- It will return boolean value if string
is matched from starting

 Case conversion methods :-


 toLowerCase() - It will convert the string into
lowercase
 toUpperCase() - It will convert the string into
uppercase

3
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

 Type conversion methods :-


 valueOf() - It will convert other data type into
string (it is static method)
 toCharArray() - It will convert the string into
character array

 Other method :
 split() - It will split the string according to
provided regex

4
Smart Programming (Mohali, Chandigarh India)
Call or Whats App Online & Industrial Training: +91 62838-30308

Company Links & Contacts

Company Name: Smart Programming (+91 62838-30308)

Address : Chandigarh & Mohali (Punjab), India

Websites: https://www.smartprogramming.in/
https://courses.smartprogramming.in

Android App:
https://play.google.com/store/apps/details?id=com.sma
rtprogramming

YouTube Channel:
https://www.youtube.com/c/SmartProgramming

You might also like