Results 1 to 1 of 1
Thread: Java
Hybrid View
-
12th May 2008 01:19 #1
Java
,
, java.lang.StringIndexOutOfBoundsExceptio n: String index out of range: 5.
:
Code:import java.io.*; public class SortAndCalculate { public static void main (String args[])throws IOException { FileReader inFile = new FileReader("output.txt"); BufferedReader in = new BufferedReader(inFile); String c[]= new String[5162]; String line; int i=0; while((line = in.readLine()) != null){ c[i]=line; i++; } c=sortStringArray(c); } static String[] sortStringArray( String in[]){ boolean vertauscht=false; boolean isgreater = false; int n=in.length; do{ vertauscht = false; for(int i=1;i<n-1;i++){ for(int p=1;p<in[i].length()-1;p++){ if(in[i].charAt(p)>in[i+1].charAt(p)){ isgreater=true; vertauscht = true; } else isgreater=false; } if (isgreater){ String buffer =in[i]; in[i]=in[i+1]; in[i+1]=buffer; } } n=n-1; }while(n>=1 && vertauscht); return in; } }
java.util .. Arrays.sort();
, .Last edited by aphex; 12th May 2008 at 02:17.
We are drowning in information, but starving for knowledge and time!




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in