我不斷收到第44行的「錯誤:無法找到符號」,我無法弄清楚我錯過了什麼符號。我確定我所有的變量都被聲明瞭。有人能幫我在我的代碼中找到問題嗎?Java符號錯誤
class personne{
private String naissance;
private int nbCafe;
public personne(String year, int number){
naissance=year;
nbCafe=number;
}
public personne(String year){
naissance=year;
nbCafe=1;
}
public String getnaissance(){
return naissance;
}
public int getnbCafe(){
return nbCafe;
}
public void afficher(String message){
System.out.println(message+ ": nee le 16 novembre 1994, consomme 2 tasse(s) de cafe");
}
public void affichertable(personne [] table, int amount,String message){
System.out.printf("Contenu du tableau de %d personne(s) %s", amount,message);
System.out.printf("Naissance nbCafe");
for (int i=0; i<amount;i++)
System.out.printf("%6.2s %8.2d\n", table[i].getnaissance(), table[i].getnbCafe());
}
}
public class popo{
public static void main(String args[]){
personne p1= new personne("16/11/1994",2);
personne p2=new personne("15/12/1990");
p1.afficher("Informations de p1");
personne[] pers={ new personne("12/10/1991",3),new personne("15/10/1990",6), new personne("13/07/1993",3), new personne("05/06/1991"),new personne("16/12/1992",3)};
int nbpers=pers.length;
affichertable(pers,nbpers,"premier tableau");//This is line 44 where the error occurs
}
}
錯誤消息告訴你哪個符號。在這種情況下,這就是'affichertable',它沒有在'popo'中聲明。 –
並請尊重命名約定。 –
但是這種方法已經在課堂上聲明瞭嗎?而即時通訊基本上只是調用它在主? – user3268216