🌐
IONOS
ionos.com › digital guide › websites › web development › java substrings
How to use the Java substring method - IONOS
January 6, 2025 - To use substring(), you’ll first enter the string that you want to extract the substring from. Then you use an integer to define where the substring should begin. You can view the output with the Java command System.out.println. The method works in­clu­sive­ly, meaning that the character that is in the position of the index you enter will also be separated.
Discussions

How to correctly use the substring method? (Java)
You are deeply confused about how substring() works - it's a method of String, and it does not take Strings as parameters. See here for an example. More on reddit.com
🌐 r/learnprogramming
5
5
February 2, 2013
Time complexity of String.Contains()
You need to understand how collections work... A string is an object but is also a collection of char structs. The IndexOf method returns the index in the array where the sequence of elements first match. Microsoft did something really smart here to reuse code, if a string contains an element/sequence it should also have an index, so they call the IndexOf method. If the method returns anything higher than -1 then it means that the collection does contain said sequence because it has an index. So to answer your question, look at the IndexOf method. More on reddit.com
🌐 r/csharp
25
1
July 16, 2020
Android Studio can't resolve my substring method.

Error message?

ss.substring(-2) - what are you trying to do here? Can't use a negative index with a substring.

What are you doing with the second wordUp.substring(length, (length - 1)); This also makes no sense.

Look in the docs at Android String

More on reddit.com
🌐 r/androiddev
3
3
January 15, 2015
How can I split a String without using the Split method?
iterate through the String, when you reach a char that matches your split value take the string from a start position to your current position and store that in your array. Keep iterating until you reach a char that does not match your split value and set that position as your new start position.... More on reddit.com
🌐 r/javahelp
19
6
February 23, 2015
🌐
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.
🌐
HappyCoders
happycoders.eu › home › java › java substring() method: how to use it and how it works
Java substring() Method: How to Use It and How It Works
4 weeks ago - Ultimately, the JDK developers weighed the pros and cons of the previous solution and decided to change the implementation in Java 7 Update 6: since then, char arrays are no longer shared between strings; instead, the substring() method (or the String constructor it calls) creates a copy of the requested section of the char array.
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › java-string-substring-method-example
Java String substring() Method with examples
Returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex – 1. Thus the length of the substring is endIndex-beginIndex. Examples: “hamburger”.substring(4, 8) returns “urge” “smiles”...
🌐
Programiz
programiz.com › java-programming › library › string › substring
Java String substring() | Programiz
January 31, 2024 - The Java substring() method extracts a part of the string (substring) and returns it.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-substring
Master Java Substring Method: Examples, Syntax, and Use Cases | DigitalOcean
February 20, 2025 - Learn how to use the Java substring method. Explore syntax, practical examples, and common errors to handle substrings effectively.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › java › lang › string_substring.htm
Java - String substring() Method
The Java String substring() method is used to retrieve a substring of a String object. The substring starts with the character at the given index and continues to the end of the current string.
🌐
CodeGym
codegym.cc › java blog › strings in java › substring in java
Java String substring()
July 23, 2024 - 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 to Java method overloading.
🌐
Igmguru
igmguru.com › home › blog › java › substring in java
Java String substring() Method: A Complete Guide
1 week ago - This method returns part of a string between two indexes. It starts from beginIndex and stops before endIndex, meaning the character at endIndex is not included in result string. ... Substring is widely used in real-world applications to extract ...
🌐
Vultr Docs
docs.vultr.com › java › standard library › java › lang › string › substring()
Java String substring() - Extract Substring | Vultr Docs
January 1, 2025 - The substring() method in Java is a fundamental tool for string manipulation, allowing developers to extract specific parts of a string based on given index positions.
🌐
Simplilearn
simplilearn.com › home › resources › software development › all you should know about substring in java
All You Should Know About Substring in Java | Simplilearn
September 11, 2025 - In this example, the substring() method is called on the str string with parameters 6 and 11. This means that the new substring will start at index 6 (which is the letter 'W' in "World") and end at index 11 (which is the last letter 'd' in "World"). The resulting substring is then assigned to the substrate variable and printed to the console. Here's an example program that uses the substring() method in Java, including some exception handling and corner cases:
Address: 5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
Baeldung
baeldung.com › home › java › java string › java string.substring()
Java.String.substring() | Baeldung
April 11, 2025 - • Java String.substring() (current ... with two signatures. If we pass the beginIndex and the endIndex to the method, then it obtains a part of a String given the starting index and the length of the result....
🌐
How to do in Java
howtodoinjava.com › home › string › java string substring()
Java String substring() with Examples - HowToDoInJava
January 10, 2023 - String substring(int beginIndex) String substring​(int beginIndex, int endIndex) The method returns the substring between the valid start and end indices.
🌐
DataFlair
data-flair.training › blogs › java-string-substring-method
Java String substring() Method with Examples - DataFlair
December 1, 2025 - The substring() method of the Java String class is a commonly used string manipulation method. It allows extracting a substring from a larger string by specifying the beginning and ending indices.
🌐
JavaBeat
javabeat.net › use-string-substring-method-java
How to Use String substring() Method in Java
In the following code, we use the substring() method to extract different substrings from the input string: public class ExtractSubstrings { public static void main(String[] args) { String inputString = "Welcome to JavaBeat.net"; int stringLen = inputString.length(); //Using Substring() With one Parameter System.out.println("String Characters From Index 11 Onwards: " + inputString.substring(11)); System.out.println("Extracting Domain Extension: " + inputString.substring(stringLen - 4)); //Using Substring() With two Parameters System.out.println("Extracting Domain Name: " + inputString.substring(11, stringLen)); System.out.println("Extracting a Specific Substring: " + inputString.substring(11, 15)); } }
🌐
Udemy
blog.udemy.com › home › it & development › software development › understating the java string substring method
Understating the Java String Substring Method - Udemy Blog
April 14, 2026 - The substring method of Java string class, when called on a String type object or a string literal, returns a new string object which is a subset of the original string on which the substring method is called.
🌐
TechVidvan
techvidvan.com › tutorials › java-string-substring
Java String substring() - TechVidvan
December 2, 2025 - A portion of a string is returned by the Java String class substring(). We pass beginIndex and endIndex number position in the Java substring method where beginIndex is inclusive, and endIndex is exclusive.
🌐
Edureka
edureka.co › blog › substring-in-java
Substring in Java | String substring() Method Example | Edureka
June 14, 2021 - A part of a string is called a Substring. In other words, substring is a subset of another string. The Java substring() method returns a new string that is a substring of this string.