Popular Tutorials
Start Learning JavaCreated with over a decade of experience.
Certification Courses
Created with over a decade of experience and thousands of feedback.
Java String Methods
- Java String split()
- Java String compareTo()
- Java String compareToIgnoreCase()
- Java String length()
- Java String replace()
- Java String replaceAll()
- Java String substring()
- Java String equals()
- Java String equalsIgnoreCase()
- Java String contains()
- Java String indexOf()
- Java String trim()
- Java String charAt()
- Java String toLowerCase()
- Java String concat()
- Java String valueOf()
- Java String matches()
- Java String startsWith()
- Java String endsWith()
- Java String isEmpty()
- Java String intern()
- Java String getBytes()
- Java String contentEquals()
- Java String hashCode()
- Java String join()
- Java String replaceFirst()
- Java String subSequence()
- Java String toCharArray()
- Java String format()
Java String subSequence()
The syntax of the subSequence() method is:
string.subSequence(int startIndex, int endIndex)
Here, string is an object of the String class.
subSequence() Parameters
The subSequence() method takes two parameters.
- startIndex - the starting index (inclusive)
- endIndex - the ending index (exclusive)
subSequence() Return Value
- The
subSequence()method returns aCharSequence.
Example: Java String subSequence()
class Main {
public static void main(String[] args) {
String str = "Java Programming";
System.out.println(str.subSequence(3, 8)); // a Pro
}
}
Did you find this article helpful?
