java tutorial - Java Stings subSequence() method - java programming - learn java - java basics - java for beginners



Java strings subsequence

Learn Java - Java tutorial - Java strings subsequence - Java examples - Java programs

Description

The subSequence () method — returns a new sequence of characters, which is a subsequence of this sequence, in other words, returns a sequence of characters from the string starting and ending with the specified indexes.

Syntax

Syntax method:

public CharSequence subSequence(int beginIndex, int endIndex)
click below button to copy the code. By - java tutorial - team

Options

Detailed information about the parameters:

  • beginIndex - initial index, inclusive;
  • endIndex - end index, not including.

Return value

  • In Java, subSequence () returns the specified subsequence.

Sample Code

import java.io.*;
public class Test {

public static void main(String args[]) {
String Str = new String("Welcome to wikitechy.com");

System.out.print("Return value:" );
System.out.println (Str.subSequence (0, 10));

System.out.print("Return value:" );
System.out.println (Str.subSequence (10, 15));
}
}
click below button to copy the code. By - java tutorial - team

Output

Return value:Welcome to
Return value: wiki

Related Searches to Java Stings subSequence() method