- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to set a range for displaying substring
Use the substring() method to set a range of substring from a string. Let’s say the following is our string.
String str = "pqrstuvw";
Getting the range of string from 3 to 6
String strRange = str.substring(3, 6);
The following is the complete example wherein we have set a range for displaying substring from a string.
Example
public class Demo { public static void main(String[] args) { String str = "pqrstuvw"; System.out.println("String: "+str); // range from 3 to 6 String strRange = str.substring(3, 6); System.out.println("Substring: "+strRange); } }
Output
String: pqrstuvw Substring: stu
- Related Articles
- Java Program for Anagram Substring Search
- Java Program to search for a Substring from a specified index
- Python program to sort strings by substring range
- Java Program to locate a substring in a string
- Java Program to Check if a string contains a substring
- Java Program to set an icon for JOptionPane
- Java program to insert a String into a Substring of StringBuffer
- Java Program to set date formats for different countries
- Java Program to set alignment for text in JLabel
- Python Program for Anagram Substring Search
- C Program for Anagram Substring Search
- How to set a specific value for a range in an R vector?
- Java Program to set Selection Mode for JList only for single selection
- How to set the range for boxplot in base R?
- Java Program to create random BigInteger within a given range

Advertisements