Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou iniciando no Java, mas não estou conseguindo encontrar o erro no código abaixo:
public class frase {
public static void main(String args[]) {
String[] lista1{"arroz", "feijao"};
String[] lista2{"macarrao", "batata"};
String[] lista3{"tomate", "beterraba"};
int npalavras1 = lista1.lenght;
int npalavras2 = lista2.lenght;
int npalavras3 = lista3.lenght;
int rand1 = (int) (Math.random() * npalavras1);
int rand2 = (int) (Math.random() * npalavras2);
int rand3 = (int) (Math.random() * npalavras3);
String phrase = lista1[rand1] + " " + lista2[rand2] + " " + lista3[rand3];
System.out.print("Precisamos de" + phrase);
}
}
Desde já agradeço pela ajuda.
Carregando comentários...