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 by לויט יהודה רובי (460 points)
edited Mar 9 by לויט יהודה רובי

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 by Peter Minarik (63,140 points)
selected Mar 10 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 by לויט יהודה רובי (460 points)
can you check it now?
commented Mar 10 by Peter Minarik (63,140 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 by לויט יהודה רובי (460 points)
thank you very much.
commented Mar 10 by Peter Minarik (63,140 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.