Skip to content
Advertisement

Why is it giving me an error when i’m calling it from inside the ‘student class?

*I have to Create a class called student

but I’m getting an error and I didn’t know how to complete the code, but what I did is:

JavaScript

Please help.

Advertisement

Answer

In order to successfully compile your program you need to create first a new object of the class Student or make the stunInfo() method static. Also the java convention for method names is to start with a lowercase later, so StunInfo should better be named ‘stunInfo’. A name like ‘printStudentInfo()’ can be considered, which would be even more readable and better shows what the method does.(Improves readability) These notes can get your example working but it is not a complete solution to the homework posted. You need perhaps to change the access modifier of the stunInfo() method to be only accessible from within the class etc.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement