About 51 results
Open links in new tab
  1. What does String.substring exactly do in Java? - Stack Overflow

    May 31, 2012 · I always thought if I do String s = "Hello World".substring(0, 5), then I just get a new string s = "Hello". This is also documented in the Java API doc: "Returns a new string that is a …

  2. java - how the subString () function of string class works - Stack Overflow

    “Substring creates a new object out of source string by taking a portion of original string”. Until Java 1.7, substring holds the reference of the original character array, which means even a sub-string of 5 …

  3. Java: Getting a substring from a string starting after a particular ...

    I have a string: /abc/def/ghfj.doc I would like to extract ghfj.doc from this, i.e. the substring after the last /, or first / from right. Could someone please provide some help?

  4. The String.substring() in java - Stack Overflow

    Dec 24, 2016 · string.substring(int id) returns a substring of the string which starts at index id. id is an index, but not the position! Remember, indexes start counting from 0! Please, check the Javadoc. …

  5. How to extract specific parts of a string JAVA - Stack Overflow

    Feb 18, 2017 · In the example code above we use the String.substring () method to gather our sub-string from within the string. To get this sub-string we need to supply the String.substring () method …

  6. Java - Strings and the substring method - Stack Overflow

    Apr 19, 2013 · Strings in Java are immutable. Basically this means that, once you create a string object, you won't be able to modify/change the content of a string. As a result, if you perform any …

  7. In Java, how do I check if a string contains a substring (ignoring case ...

    In Java, how do I check if a string contains a substring (ignoring case)? [duplicate] Asked 16 years ago Modified 4 years, 2 months ago Viewed 1.3m times

  8. java - substring index range - Stack Overflow

    14 Both are 0-based, but the start is inclusive and the end is exclusive. This ensures the resulting string is of length start - end. To make life easier for substring operation, imagine that characters are …

  9. java - Find the Number of Occurrences of a Substring in a String ...

    3 Matcher.results() You can find the number of occurrences of a substring in a string using Java 9 method Matcher.results() with a single line of code. It produces a Stream of MatchResult objects …

  10. How to get the last characters in a String in Java, regardless of ...

    Jul 14, 2010 · I'm looking for a way to pull the last characters from a String, regardless of size. Lets take these strings into example: "abcd: efg: 1006746" "bhddy: nshhf36: 1006754" "hfquv: nd: 5894254" …