About 11,000,000 results
Open links in new tab
  1. How to get the last characters in a String in Java, regardless of ...

    Jul 14, 2010 · String numbers = text.substring(text.length() - 7, text.length()); But be sure to catch Exception if the input string length is less than 7 . You can replace 7 with any number say N, if …

  2. 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.

  3. java - Last substring of string - Stack Overflow

    May 4, 2010 · For those looking to get a substring after some ending delimiter, e.g. parsing file.txt out of /some/directory/structure/file.txt. I found this helpful: StringUtils.substringAfterLast. …

  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. substring - Java: simpler way of cutting off end of string - Stack Overflow

    Oct 6, 2014 · You want to get the st1 string without last two characters, so when we use the substring() in Java we have to give the start point and end point of the sub-string. In my code, i …

  6. Get Substring from String in Java - Baeldung

    Jul 21, 2024 · In this quick tutorial, we’ll focus on the substring functionality of Strings in Java. We’ll mostly use the methods from the String class and few from Apache Commons’ …

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

  8. Java String substring() with Examples - HowToDoInJava

    Learn to find the substring of a string between the begin and end indices, and valid values for both indices with examples. Learn to get a substring from from given String in Java between the …

  9. Extract substring from end of a Java String – zParacha.com

    Today I’ll show you how to extract last few characters (a substring) from a string in Java. Here is the code to do this. public class SubStringEx{ /** Method to get the substring of length n from …

  10. 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.