aspose file tools*
The moose likes Beginning Java and the fly likes Why can student[x] be resolved? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why can student[x] be resolved?" Watch "Why can student[x] be resolved?" New topic
Author

Why can student[x] be resolved?

Aaron Parker
Greenhorn

Joined: Jan 31, 2004
Posts: 27
The compiler has no problem resolving student[x] in line 61, but can't figure it out in line 44? Why not?
I'm getting this compiler error:
src/java192/project3/GradePoint.java:44: cannot resolve symbol
symbol : variable getStudentNumber
location: class Student
student[1].getStudentNumber +
^
(carat under [ )
My code:


(Marilyn added code tags)
[ March 06, 2004: Message edited by: Marilyn de Queiroz ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
It is helpful if you

1) Put your code in code tags when you post it

2) Point out which line is in question

for example:

student[x].getStudentNumber + // line 61


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Aaron Parker
Greenhorn

Joined: Jan 31, 2004
Posts: 27
How does one add code tags?
The compiler has no problem resolving student[x] in line 61, but can't figure it out in line 44? Why not?
I'm getting this compiler error:
src/java192/project3/GradePoint.java:44: cannot resolve symbol
symbol : variable getStudentNumber
location: class Student
student[1].getStudentNumber +
^
(carat under [ )
My code:

code:
--------------------------------------------------------------------------------
public class GradePoint { /** Description of the Field */ public static char validGrades[] = {'A', 'B', 'C', 'D', 'F'}; /** Description of the Field */ public static char tempGrade; private static Student[] student = new Student[2]; /** Description of the Field */ public static boolean found = false; /** * Description of the Method * *@exception Exception Description of the Exception */ public static void assignGrades() throws Exception { instantiateStudents(); getStudentData(); displayGrades(); } /** Description of the Method */ public static void instantiateStudents() { for (int x = 0; x < 2; ++x) { student[x] = new Student(); } } /** * Gets the studentData attribute of the GradePoint class * *@exception Exception Description of the Exception */ public static void getStudentData() throws Exception { for (int x = 0; x < 2; ++x) { for (int y = 0; y < 5; ++y) { System.out.print("Please enter Student #" + student[x].getStudentNumber +// line 44 "'s grade for class #" + (y + 1) + ": "); tempGrade = (char) System.in.read(); System.in.read(); System.in.read(); found = false; for (int z = 0; z < 5; ++z) { String tempGradeString = Character.toString(tempGrade); String validGradesString = Character.toString(validGrades[z]); if (tempGradeString.equals(validGradesString)) { found = true; if (found == false) { System.out.println("Invalid entry--please reenter."); --y; } System.out.println(x); student[x].setGrade(y, tempGrade);//line 61 } } } } } /** Description of the Method */ public static void displayGrades() { student[0].toString(); System.out.println(student[0].toString()); student[1].toString(); System.out.println(student[1].toString()); }}
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Since you don't have all your code posted (specifically the Student class), I will look into my crystal ball and predict that getStudentNumber has not been defined in the Student class or it is actually a method and you forgot the parenthesis :getStudentNumber()


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Aaron Parker
Greenhorn

Joined: Jan 31, 2004
Posts: 27
Crud, sorry. Tried to add line numbers and it didn't work. Line 44 reads: student[x].getStudentNumber +
and line 61 reads: student[x].setGrade(y, tempGrade);
Aaron Parker
Greenhorn

Joined: Jan 31, 2004
Posts: 27
THANK YOU Mr. Morris! I would like to purchase one half dozen of your crystal balls! It was a method without ().
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why can student[x] be resolved?