title: How to convert String into number and sort it?
body: <p>Could somebody tell me the way to break down problem. The requirement is display a menu with choice bubble sort, insertion sort. Allow user to input infinite number and sort those numbers base on their choice. I am lost. This is the code I have been working on. I am confused how to let user input a String and split them to int and sort them, and how can we output the result in toString().</p>
  
  <pre><code>public class IntegerArraySorting{
      private int[] integerArray;
      int sortingMethod;
  
      public IntegerArraySorting(String listNumber, int sortingMethod) {
          //StringTokenizer strToken = new StringTokenizer(listNumber, " ");
          for(int i = 0; i &lt; listNumber.length(); i++){
              integerArray[i] = Integer.parseInt(listNumber);
          }
          switch(sortingMethod){
          case 1: 
              System.out.println("Sorting method: BUBBLE SORT");
              //Integer.parseInt(listNumber).bubbleSort();
              break;
              default:
                  System.out.println("Wrong Input");
          }
  
      }
  
      public void insertionSort() {
          for (int i = 1; i &lt; integerArray.length; i++) {
              int j = i;
              int B = integerArray[i];
              while ((j &gt; 0) &amp;&amp; (integerArray[j - 1] &gt; B)) {
                  integerArray[j] = integerArray[j - 1];
                  j--;
              }
              integerArray[j] = B;
          }
      }// where array is an array with size = n
  
      public void bubbleSort() {
          int n = integerArray.length;
          for (int pass = 1; pass &lt; n; pass++) { // count how many times
              // This neintegerArrayt loop becomes shorter and shorter
              for (int i = 0; i &lt; n - pass; i++) {
                  if (integerArray[i] &gt; integerArray[i + 1]) {
                      // exchange elements
                      int temp = integerArray[i];
                      integerArray[i] = integerArray[i + 1];
                      integerArray[i + 1] = temp;
                  }
              }
          }
      }// where integerArray is an array with size = n
  
      public void selectionSort() {
          for (int i = 0; i &lt; integerArray.length - 1; i++) {
              for (int j = i + 1; j &lt; integerArray.length; j++) {
                  if (integerArray[i] &gt; integerArray[j]) {
                      // ...Exchange elements
                      int temp = integerArray[i];
                      integerArray[i] = integerArray[j];
                      integerArray[j] = temp;
                  }
              }
          }
      }// where integerArray is an array with size = n
  
      public String toString(){
          String str = "";
          for(int i = 0; i &lt; integerArray.length; i++){
           str = str + Arrays.toString(integerArray);
          }
          return str;
      }
  
  }
  </code></pre>