0

I am having errors below and I am confused why this is a Lab to make a storage spot for a students information.

import java.util.Arrays;

I have a problem with the square brackets below

public class Student {
    private String studentID;
    private String studentName;
    private String studentMajor;
    private double studentGPA;
    private String studentGrad;
    private long[] ;

And a problem with Student() below

    public Student(){
        studentID = "";
        studentName = "";
        studentMajor = "";
        studentGPA = 0;
        studentGrad = "";
    }   

    public Student(String stuID, String stuName, String stuMajor, double stuGPA, String stuGrad) {
        studentID = stuID;
        studentName = stuName;
        studentMajor = stuMajor;
        studentGPA = stuGPA;
        studentGrad = stuGrad;
    }

    public void setID(String ID) {
        studentID = ID;
    }

    public void setName(String name) {
        studentName = name;
    }

    public void setMajor(String major) {
        studentMajor = major;
    }

    public void setGPA(double GPA) {
        studentGPA = GPA;
    }

    public void setGrad(String Grad) {
        studentGrad = Grad;
    }

    public String getID() {
        return studentID;
    }

    public String getName() {
        return studentName;
    }

    public String getMajor() {
        return studentMajor;
    }

    public double getGPA() {
        return studentGPA;
    }

    public String getGrad() {
        return studentGrad;
    }

    public void printData() {
        System.out.println("Student ID: "+studentID);
        System.out.println("Student Name: " +studentName );
        System.out.println("Student Major: "+studentMajor); 
        System.out.println("Student GPA: "+ studentGPA); 
        System.out.println("Student Year of Graduation: " +studentGrad);
    }
}
1
  • Post the error messages you're getting. Commented Sep 9, 2015 at 16:23

1 Answer 1

2

private long[]; is incorrect syntax.

To complete the variable you must insert an identifier (the variable name).

In most IDE's (i.e. Eclipse and Netbeans), this incomplete variable will cause the next line to have issues. This is why public Student(){ (despite being completely valid code) is giving you an error. If you temporarily delete the line private long[]; you should see this error go away.

From the code you supplied, it looks like private long[]; can be deleted anyway as an array isn't being used.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.