About 446,000 results
Open links in new tab
  1. java - For loop with substrings - Stack Overflow

    Oct 23, 2013 · for (int i=0;i<len;i++) { for (int k=0;k<len-i;k++) System.out.print(s.substring(k,k+i+1)+","); } This as your for structure should work. At each step inner loop, the number of strings to print decreases (using -i).

  2. java - Substring with the loop - Stack Overflow

    May 13, 2011 · In below code I am trying to do substring based on start and end index,But in end of the string.System is throwing ArrayIndexOutOfBoundsException. Please let me know, how to resolve this issue.

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

  4. All substrings of a given String - GeeksforGeeks

    Feb 14, 2025 · Given a string s, containing lowercase alphabetical characters. The task is to print all non-empty substrings of the given string. Examples : The idea is to use two nested loops. The idea is to recursively generate all possible substrings of the given string s.

  5. 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’ StringUtils class. In all of the following examples, we’re going to using this simple String:

  6. How to Split a String into Equal Length Substrings in Java?

    Nov 29, 2024 · In Java, splitting a string into smaller substrings of equal length is useful for processing large strings in manageable pieces. We can do this with the substring method of the loop. This method extracts a substring of the specified length from the input string and stores it …

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

  8. 4.3. Loops and Strings — AP CSAwesome - runestone.academy

    String substring(int from): returns substring(from, length()). 4.3.1. While Find and Replace Loop¶ A while loop can be used with the String indexOf method to find certain characters in a string and process them, usually using the substring method.

  9. Loops and Strings | Think Java | Trinket

    The substring method returns a new string that copies letters from an existing string, given a pair of indexes: fruit.substring(0, 3) returns "ban" fruit.substring(2, 5) returns "nan"

  10. Java String Split Every N Characters: A Comprehensive Guide

    Using the String.substring() Method. The simplest way to split a string into chunks of N characters is by using the `substring()` method in a loop. This method extracts a portion of a string based on specified indices.

  11. Some results have been removed
Refresh