1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
|
//Instanzvariablen
private String[] sArray, copy;
private int max;
private int n = 0;
public String getAlphabeticFirst(){
if(sArray[0] == null){
return "";
}
else if(n == 0){
copy = new String[max];
}
//sArray wird rekursiv kopiert
if(n < max && sArray[n] != null){
copy[n] = sArray[n];
n++;
return getAlphabeticFirst();
}
//die Nulls werden durch z ersetzt
else if(n < max){
copy[n] = "z";
n++;
return getAlphabeticFirst();
}
//die Kopie wird alphabetisch sortiert
else{
Arrays.sort(copy);
n = 0;
return copy[0];
}
} |