About 23,900 results
Open links in new tab
  1. java - substring index range - Stack Overflow

    public String substring(int beginIndex) beginIndex—the begin index, inclusive. Returns a sub string starting from beginIndex to the end of the main String. Example: public class Test { …

  2. java - Indexes of all occurrences of character in a string - Stack Overflow

    public static int[] indexesOf(String s, String flag) { int flagLen = flag.length(); String current = s; int[] res = new int[s.length()]; int count = 0; int base = 0; while(current.contains(flag)) { int index = …

  3. Searching For Characters and Substring in a String in Java

    Dec 2, 2024 · In this article, we will explore essential methods like indexOf (), contains (), and startsWith () to search characters and substrings within strings in Java. 1. Using indexOf(char …

  4. 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 …

  5. Java: substring index position - Stack Overflow

    Oct 24, 2017 · If your string is Welcome to Java, str.substring(5) will give you the string from index 5 up to the last ch so your output will be me to Java. Index starts from 0.

  6. 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 …

  7. Get Substring from String in Java - Baeldung

    Jul 21, 2024 · Let’s start with a very simple example here – extracting a substring with the start index: assertEquals("USA (United States of America).", text.substring(67)); Note how we …

  8. Java String.substring() - Baeldung

    Apr 11, 2025 · String sub = s.substring(0, 20); A quick example and explanation of the substring () API of the standard String class in Java.

  9. 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 …

  10. Understanding the substring() Method in Java: Start and End Indexes

    In Java, the substring() method is used to extract a portion of a string based on specified start and end indices. The design choice of using an inclusive start index and an exclusive end index …

Refresh