A bubble sort for Strings. : String Find Search « Data Type « Java Tutorial





class SortString {
  static String arr[] = { "N", "i", "t", "t", "f", "a", "g" };

  public static void main(String args[]) {
    for (int j = 0; j < arr.length; j++) {
      for (int i = j + 1; i < arr.length; i++) {
        if (arr[i].compareTo(arr[j]) < 0) {
          String t = arr[j];
          arr[j] = arr[i];
          arr[i] = t;
        }
      }
      System.out.println(arr[j]);
    }
  }
}










2.29.String Find Search
2.29.1.Find the latest index of any of a set of potential substrings.
2.29.2.Find the first index of any of a set of potential substrings.
2.29.3.Finds the first index within a String, handling null.
2.29.4.Finds the last index within a String from a start position, handling null.
2.29.5.Finds the n-th index within a String, handling null.
2.29.6.Use String.indexOf to locate a character in a string
2.29.7.Use String.lastIndexOf to find a character in a string
2.29.8.Use String.indexOf to locate a substring in a string
2.29.9.Use lastIndexOf to find a substring in a string
2.29.10.Demonstrate indexOf() and lastIndexOf().
2.29.11.Extract Substring with indexOf
2.29.12.Java String endsWith
2.29.13.Java String startsWith
2.29.14.Starts with, ignore case( regular expressions )
2.29.15.Ends with, ignore case( regular expressions )
2.29.16.Anywhere, ignore case( regular expressions )
2.29.17.Last occurrence of a character
2.29.18.Not found returns -1
2.29.19.A bubble sort for Strings.
2.29.20.Search a String to find the first index of any character in the given set of characters.
2.29.21.Search a String to find the first index of any character not in the given set of characters.