Why can't I call a public method in another class?

后端 未结 4 667
臣服心动
臣服心动 2021-02-05 22:27

I have got these two classes interacting and I am trying to call four different classes from class one for use in class two.

The methods are public and they do return va

4条回答
  •  难免孤独
    2021-02-05 22:44

    You have to create a variable of the type of the class, and set it equal to a new instance of the object first.

    GradeBook myGradeBook = new GradeBook();
    

    Then call the method on the obect you just created.

    myGradeBook.[method you want called]
    

提交回复
热议问题