About 163,000 results
Open links in new tab
  1. Java String substring() Method - W3Schools

    The substring() method returns a substring from the string. If the end argument is not specified then the substring will end at the end of the string.

  2. Java String substring() Method - GeeksforGeeks

    Apr 11, 2025 · In Java, the substring() method of the String class returns a substring from the given string. This method is most useful when you deal with text manipulation, parsing, or data extraction. This method either takes 1 parameter or 2 parameters, i.e., …

  3. Java String substring() with Examples - HowToDoInJava

    The String.substring() in Java returns a new String that is a substring of the given string that begins from startIndex to an optional endIndex. These indices determine the substring position within the original string.

  4. Java String substring() Method with examples - BeginnersBook

    Sep 17, 2022 · The substring() method is used to get a substring from a given string. This is a built-in method of string class, it returns the substring based on the index values passed to this method. For example: "Beginnersbook".substring(9) would return "book" as a substring. This method has two variants, one is where you just specify the

  5. Java String substring() - Programiz

    The Java substring() method extracts a part of the string (substring) and returns it. Example class Main { public static void main(String[] args) { String str1 = "java is fun"; // extract substring from index 0 to 3

  6. Master Java Substring Method: Examples, Syntax, and Use Cases

    Feb 20, 2025 · In this tutorial, we’ll cover its syntax, use cases, and potential pitfalls while providing practical examples and solutions to common errors. Parameters: beginIndex - the starting index (inclusive). endIndex (optional) - the ending index (exclusive). Java String substring method is overloaded and has two variants.

  7. Get Substring from String in Java - Baeldung

    Jul 21, 2024 · The practical ways of using the useful substring functionality in Java - from simple examples to more advanced scenarios.

  8. Substring in Java with Examples - First Code School

    Jan 10, 2024 · Here is an example of a program that uses the substring () method that slices up the string “FirstCode”: Output: 2. Specifying both startIndex and endIndex. The substring () method returns a new string that is a part of the given string. The substring starts at the specified start index and ends at the specified end index.

  9. Java String substring() example - Java Guides

    In this guide, you will learn about the String substring () method in Java programming and how to use it with an example. 1. String substring () Method Overview. The substring () method of Java's String class returns a new string that is a substring of the given string. 2. str. substring (int beginIndex, int endIndex)

  10. Java String substring() Method - Java Guides

    The String.substring() method in Java is used to extract a portion of a string. This guide will cover the method's usage, explain how it works, and provide examples to demonstrate its functionality.

Refresh