Ciao a tutti devo fare come esercizi un metodo ricorsivo che trovi il massimo tra gli elementi di un array di double io ho provato a scrivere questo:
codice:
class MassimoArray{
public static void main (String[] args) {
double[] x = {1.2,1.4,1.6,1.8,1.1};
System.out.println(Massimo(max,0,0));
}
static double Massimo(double[] x, double max, int indice, double massimo ) {
if ( indice < x.length ) {
max = (max,indice + 1);
if (x[indice] > max) {
max = x[indice];
}
}
return max;
}
}
Ma genere questi 2 erroei:
javac "MassimoArray.java"
----------
1. ERROR in MassimoArray.java (at line 5)
System.out.println(Massimo(max,0,0));
^^^
max cannot be resolved
----------
2. ERROR in MassimoArray.java (at line 10)
max = (max,indice + 1);
^
Syntax error on token ",", . expected
----------
2 problems (2 errors)
Compilazione fallita.
dove è l'errore e dai giorni che mi sono bloccato