Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

classes don't activate

+4 votes
asked Mar 9, 2022 by לויט יהודה רובי (500 points)
edited Mar 9, 2022 by לויט יהודה רובי
https://onlinegdb.com/KtS1y9KnWE

I don't know what is the problem.

I've checked it, and the program is perfect. but only on gdb online it doesn't work.

1 Answer

0 votes
answered Mar 9, 2022 by Peter Minarik (84,720 points)
selected Mar 10, 2022 by לויט יהודה רובי
 
Best answer

The link you provided is broken. (Here is an example of a working link.)

Click on the SHARE button (3 to the right from the RUN button) and get the link from there to your project.

commented Mar 9, 2022 by לויט יהודה רובי (500 points)
can you check it now?
commented Mar 10, 2022 by Peter Minarik (84,720 points)
OnlineGDB doesn't like when the Main class is in a package. Just remove the

package person;

line from both of your files and after this, your program will run.

That being said, it doesn't mean it works correctly. For instance, it will throw a NullPointerException as your p is set to a new array or Persons, but the individual elements in the array are not initialized (are null) and trying to access them in details() function leads to the aforementioned exception.

If you fix that, you'll run into a ArrayIndexOutOfBoundsException in your sortByHight() function.

I stopped checking for more problems at this point.

Keep an eye open for those pesky bugs! :)
commented Mar 10, 2022 by לויט יהודה רובי (500 points)
thank you very much.
commented Mar 10, 2022 by Peter Minarik (84,720 points)
My pleasure.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...