簡體   English   中英

找不到符號錯誤Netbeans

[英]Cannot find symbol error Netbeans

嗨,我是Java的新手,我正在編寫一個簡單的程序來模擬跳水比賽。 我使用NetBeans,但無法找出為什么會出現此錯誤。 代碼是這樣的:

package agoneskataduseon;
import java.util.Scanner;

public class AgonesKataduseon {

 public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
      int numAth, numJud, numDiv;
      System.out.print("Give the number of the athletes in the competition : ");
      numAth = input.nextInt();
      System.out.print("Give the number of the judges : ");
      numJud = input.nextInt();
      System.out.print("Give the numbe rof dives : ");
      numDiv = input.nextInt();
      DivingCompetition game = new Diving Competition(numAth, numJud, numDiv);
  }
}

DivingCompetition類(尚未結束):

import java.util.Scanner;
public class DivingCompetition {
    int numa;
    int numj;
    int numd;
    Athlete[] arr1 = new Athlete[12];
    Athlete[] arr2 = new Athlete[12];

    public DivingCompetition(int numAthletes, int numJudges, int numDives){
        numa = numAthletes;
        numj = numJudges;
        numd = numDives;
    }

    public void readAthletesName(){
        String nam;
        int i=0;
        Scanner input = new Scanner(System.in);
        while(i < numa){
            System.out.print("Give the name of athlete num "+(i+1)+" : ");
            nam = input.nextLine();
            arr1[i] = new Athlete(nam);
            i++;
        }
    }

    public void runCompetition(){
        int i=0;
        Dive dv = new Dive(numj);
        while(i<12){
           arr1[i].addDive(dv);
        }
   }
}

記錄一下運動員課程:

public class Athlete {
        String names;
        Dive[] arrayd = new Dive[6]; 
        double fullScore;
        int point;

    public Athlete(String name){
        names = name;
        fullScore = 0;
        point = 0;
    }

    public void addDive(Dive dive){
        arrayd[point] = dive;
        fullScore = fullScore + arrayd[point].computeScore();
        point++;
    }
}

我也會給你潛水課,但我看不出這樣做的意義

NetBeans在主函數中給我一個錯誤:找不到符號符號:類DivingCompetition位置:類AgonesKataduseon

我的問題是為什么它會給我這個錯誤? 如果我嘗試在主要功能內制作運動員或潛水的對象,也會發生此問題

如果您需要,Netbeans將嘗試提供幫助,並為您提供修復代碼的建議。 您所要做的就是將光標放在問題所在的行上,然后按Alt + Enter

修正碼

當您將鼠標懸停在錯誤的語句上時,它實際上會在錯誤消息的底部為您提供此鍵盤快捷鍵。

有關更多信息,請參見手冊中的“代碼協助”頁面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM