【问题标题】:"Cannot find Symbol" error in Java method definitionJava 方法定义中的“找不到符号”错误
【发布时间】:2014-08-15 16:23:25
【问题描述】:

我是一名计算机科学专业的学生,​​刚刚进入真正的面向对象编程领域,我假设我的问题与对初始化对象的理解不够好有关。

我得到了必须处理读取/写入文件的作业,我可以很好地处理,如果我能够编写自己的 main 方法,并且从头开始,我觉得我可以在不到一分钟的时间内完成然而,一个小时......在家庭作业中,我们上了一门我们不能改变的主课。他还给了我另一种开始的方法。它们如下:

import java.io.*;
import java.util.*;

public class CSCD211Lab1
{
private static final int TEAMS = 32;

public static void main(String [] args)throws Exception
{
    int choice;
    Scanner kb = new Scanner(System.in);

  Team [] worldCupTeams = null;

  worldCupTeams = fillTeamsArray(kb);

    do
    {
        choice = menu(kb);
        executeChoice(choice, worldCupTeams);

    }while (choice != 8);

}// end main

public static Team [] fillTeamsArray(Scanner kb)throws Exception
{      
  return null;     

}// end fillTeamArray

public static Player [] readPlayers(String filename)throws Exception
{
   return null;

}// end readPlayers

public static int menu(Scanner kb)
{
    /*
    1.  Print all Teams to the screen
    2.  Print all Teams to the User Specified file
    3.  Sort the Teams by “Natural Order” (Hint: compareTo)
    4.  Sort the by Team Country Name (Hint: Comparator)
    5.  Sort each Team's Players by Number (Hint: Player compareTo)
    6.  Sort each Team's Players by Position (Hint: Comparator)
    7.  Print a entire team and only that team to a user specified file
    8.  Quit
    */
return 8;

}// end menu

public static void executeChoice(int choice, Team [] array)throws Exception
{


}// end executeChoice

public static void printArray(PrintStream out, Team [] array)
{

}// end printArray

}// end class 

我的问题是为什么这会导致 public static Team [] fillTeamsArray 出现“找不到符号”错误?我假设我需要在 fillTeamsArray 中对其进行一些定义,但任何时候我尝试都会遇到同样的错误。我不是在找人来做我的功课,我只是在寻找朝着正确方向前进的动力。我转到了学校,而我已经完成的先决条件肯定没有涵盖它应该具备的一点材料。

感谢任何帮助! 谢谢!

【问题讨论】:

  • 请向我们展示完整的编译错误信息。
  • Team 课程是给你的吗?还是一定要写?

标签: java arrays oop object symbols


【解决方案1】:

您需要导入类Team。编译器无法识别Team。这堂课在哪里?在 CSCD211Lab1 类中导入。

【讨论】:

  • Team 必须由学生编写。那将是要做的事情。否则它就不是真正的 OOP。
【解决方案2】:

使用像 intellij 这样的 IDE,我不知道这是否是一个好的开始方式,但它会让你更容易: * 如果您使用默认包,它会警告您。 * 没有更多的导入或拼写错误问题...

【讨论】:

    猜你喜欢
    • 2021-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-28
    • 1970-01-01
    • 2018-11-08
    相关资源
    最近更新 更多