用冒泡法,对未知数据从小到大排序!(有错误)
程序代码:
package ai; import *; public class wo { public static void main(String[] args) { String[]intArray; intArray = new String[3]; int i; for (i = 0; i < intArray.length; i++) { System.out.println("Please input data for stringArray " + i); try { BufferedReader in = new BufferedReader(new InputStreamReader( System.in)); intArray[i] = in.readLine(); } catch (IOException e) { e.printStackTrace(); } } int j,m; int l=intArray.length; for (j = 0; j < l-1; j++) for (m = j + 1; m < l; m++) if (intArray[j] > intArray[m]) { int t =intArray[j]; intArray[j] = intArray[m]; intArray[m] = t; } for (j = 0; j <intArray.length; j++) { System.out.println(intArray[j] + " "); } } }
---------------------------------------------------------------------------
" border="0" />
----------------------------------------------------------------------------
错误的原因是不是intArray[j]还没有赋值,请问接下来该怎么改动?
---------------------------------------------------------------------------
帮我看下,非常感谢!