It's supposed to be an efficiency measure. i.e. when you're taking a substring you won't create a new char array, but merely create a window onto the existing char array.

Is this worthwhile ? Maybe. The downside is that it causes some confusion (e.g. see this SO question), plus each String object needs to carry the offset info into the array, even if it's not used.

EDIT: This behaviour has now changed as of Java 7. See the linked answer for more info

Answer from Brian Agnew on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › String.html
String (Java Platform SE 8 )
April 21, 2026 - The class String includes methods ... for extracting substrings, and for creating a copy of a string with all characters translated to uppercase or to lowercase. Case mapping is based on the Unicode Standard version specified by the Character class. The Java language provides ...
🌐
W3Schools
w3schools.com › java › ref_string_substring.asp
Java String substring() Method
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A ... The substring() method returns a substring from the string.
🌐
GeeksforGeeks
geeksforgeeks.org › java › substring-in-java
Java String substring() Method - GeeksforGeeks
April 11, 2025 - In Java, the substring() method of the String class returns a substring from the given string.
🌐
Codecademy
codecademy.com › docs › java › strings › .substring()
Java | Strings | .substring() | Codecademy
April 28, 2025 - The .substring() method in Java returns a portion of a string from a specified starting index to an (optional) ending index.
🌐
CodeGym
codegym.cc › java blog › strings in java › substring in java
Java String substring()
Java Substring in general is a contiguous sequence of characters inside the String. It could be a part of the String or the whole String as well. What is substring in Java? This language has a substring() method, or rather two methods, thanks ...
Published   July 23, 2024
🌐
DevGenius
blog.devgenius.io › java-substring-a-comprehensive-guide-082192995d1e
Java Substring Failed When Input Changed Shape | Dev Genius
1 week ago - substring(int beginIndex, int endIndex) – Extracts a substring starting at beginIndex and ending at endIndex - 1. ... I write about production failures in Java backend systems: Spring Boot, Kafka, Redis, PostgreSQL, and the trade-offs that only show up after launch.
Find elsewhere
🌐
Medium
maheshjtp.medium.com › what-is-a-substring-in-java-syntax-applications-of-java-substring-9abbf79350e9
What is a Substring in Java? Syntax/ Applications of Java Substring | by Mahesh Sharma | Medium
March 7, 2025 - In the realm of Java programming, the substring functionality stands as a powerful tool for manipulating and extracting portions of text data within strings.
🌐
Baeldung
baeldung.com › home › java › java string › get substring from string in java
Get Substring from String in Java | Baeldung
July 21, 2024 - For more details on the Java regular expressions check out this tutorial. We can use the split method from the String class to extract a substring. Say we want to extract the first sentence from the example String.
🌐
YouTube
youtube.com › watch
Java substrings are easy! 📧 - YouTube
#java #javatutorial #javacourse This is a beginner's introduction to substrings and we'll use it to code an email slicer that extracts a username and domain ...
Published   December 5, 2024
🌐
Igmguru
igmguru.com › blog › substring-in-java
Java String substring() Method: A Complete Guide | igmGuru
May 11, 2026 - Learn what is substring and how this contiguous sequence of characters within a string (Java Class) is used to extract specific portions of text with this Java tutorial.
🌐
IONOS
ionos.com › digital guide › websites › web development › java substrings
How to use the Java substring method - IONOS
January 6, 2025 - If you want to extract a specific subset from the larger string, you have several options. The method Java String.split() breaks an entire string down into its in­di­vid­ual parts to, for example, give you a clearer overview of the string. The method substring() takes that one step further and returns only the part of the string that you define.
🌐
Reddit
reddit.com › r/learnprogramming › how to correctly use the substring method? (java)
r/learnprogramming on Reddit: How to correctly use the substring method? (Java)
February 2, 2013 -

Hey guys, I've been working on this Java homework for my class and this whole section about string manipulation is confusing me.

The homework asks to add statements that use the substring method to get the first half and second half of phrase.

I'm assuming that means using the substring method, but I always get errors trying to compile what I put in. So here's the code. I'm not exactly sure how to use the substring method in the way they ask, and my book doesn't really go over it well. Should I be creating another variable or just use what I have?

🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.string.substring
String.Substring Method (Java.Lang) | Microsoft Learn
Returns a string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1.
🌐
HappyCoders.eu
happycoders.eu › java › substring
Java substring() Method
June 12, 2025 - String string = "the quick brown fox jumps over the lazy dog"; string = string.replace("the", "a");Code language: Java (java) To remove a substring, we can replace it with the empty string "".
🌐
FavTutor
favtutor.com › blogs › java-substrings
Substring in Java (with examples)
November 5, 2023 - In Java, the substring is a powerful method that allows developers to extract subsets or parts of a string. By using the substring() method, you can create smaller strings from a bigger one without modifying the original string.
🌐
LeetCode
leetcode.com › problems › minimum-window-substring
Minimum Window Substring - LeetCode
Can you solve this real interview question? Minimum Window Substring - Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window. If there is no such substring, return the empty string "". The testcases will be generated such that the answer is unique.
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › substring-java
Substring in Java: Everything You Need to Know
April 18, 2026 - A string extracted from a larger string is known as a Substring. They come under the class of java.lang.String. A built-in method known as substring() is available in the String class of Java that extracts a substring from the given string where ...