I think the fourth requirement is used in line 19 and the fifth in line 32, why are they Fault?
package de.codegym.task.task08.task0830;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/*
Aufgabe zu Algorithmen
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String[] array = new String[20];
for (int i = 0; i < array.length; i++) {
array[i] = reader.readLine();
}
array=sortieren(array);
for (String x : array) {
System.out.println(x);
}
}
public static String[] sortieren(String[] array) {
String[] sortiert = new String[array.length];
for(int i= 0;i < array.length; i++){
int counter = 0;
for(int j =0 ;j < array.length;j++){
if(j!=i){
if(istGroesserAls(array[i], array[j])){
counter++;//schreib hier deinen Code
}
}
}
sortiert[counter]=array[i];
}
array=sortiert;
return array;
}
// String-Vergleichsmethode: 'a' ist größer als 'b'
public static boolean istGroesserAls(String a, String b) {
return a.compareTo(b) > 0;
}
}