找不到符号错误Netbeans

时间:2016-11-27 18:29:11

标签: java 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在main函数中给出了一个错误: 找不到标志         符号:DivingCompetition类         地点:AgonesKataduseon课程

我的问题是为什么它给了我这个错误? 如果我试图在主要功能中制作一个运动员或潜水对象

,也会发生这个问题

1 个答案:

答案 0 :(得分:0)

如果您提出要求,Netbeans会尽力帮助并为您提供修改代码的建议。您所要做的就是将光标放在问题所在的行上,然后按 Alt + Enter

Fix Code

当您将鼠标悬停在错误的语句上时,它实际上会在错误消息的底部为您提供此键盘快捷键。

有关详细信息,请参阅手册中的Code Assistance页面。