JUnit is a framework to produce tests. He knows better than programmers how to do it right. Everything is ready for your use. Of course the programmer needs to know how to use it.
The advantage of testing is whether the method is meeting the requirements specified in the test itself. You can modify your normal methods and run JUnit to see if your modifications did not compromise the result of the modified method. You'll see more advantages when dealing with large code bases. But you're learning to do it right from the start, even in exercise codes.
Specifically JUnit has a structured way to manipulate the tests and deal with their results. If you write them the way JUnit requires, the tool will be able to make the best use of this information and determine if everything is okay, all without human intervention. This way can help integrate with other JUnit-compatible tools.
Proper use of your resources can better document problems encountered if a test fails. This is useful for many tools and for the whole team. Whenever you have a standard shape you will have the most organized work.
It can, as a whole, help create tests and data to confront behavior, as well as facilitate certain types of tests that would require a specific infrastructure to run. Obviously it's just a process automation tool. It does not make your code look better, nor does it make your tests correct. If the tests are poorly written, little or nothing helps. It can give productivity and reduce the boring part of writing tests in addition to avoiding some common mistakes and forgetting.
In addition, it encourages you to create pre-code tests, called TDD .