简体   繁体   中英

“Cannot find Symbol” error in Java method definition

I'm a Computer Science major just getting into real object oriented programming, and I'm assuming my problem has to do with not understanding initializing objects well enough.

I was given homework that has to deal with reading/writing to a file which I can handle just fine, and if I was able to write my own main method, and start from scratch I feel I could finish in less than an hour, however... In the homework we were give a main class that we CANNOT change. He also gave me a other methods to start. They are as follows:

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 

My question is why does this cause a "cannot find symbol" error for public static Team [] fillTeamsArray ? I'm assuming I need to somewhat define it in fillTeamsArray but any time I try I get the same error. I'm not looking for someone to do my homework I'm just looking for a push in the right direction. I transferred to the school and the equivalent to the prerequisite I already took must have not covered a bit of the material it should have.

Any help is appreciated! Thanks!

You need to import class Team . Compiler is no able to recognize Team . Where is this class? Import it in class CSCD211Lab1 .

Use an IDE like intellij, I don't know if it's a good way to start but it will make it easier for you : * it warns you if you are using default package. * no more import or misspelling issues...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM