Matthew F. answered 04/05/19
Professional Software/ Web Developer Specializing in Java
The role of asserts is to stop the program if an input or value is not within a desired range. Some other examples would be making sure a users input is within bounds or does not contain any undesired characters. Generally used for developers benefit only, as assertions can quickly pinpoint potential causes for errors. Also useful in making sure that the input for a method is valid (precondition) and that it performed the operation as expected and the value to be returned is within desired ranges (post condition).
The syntax of assert ____ : "Error message" is just one option. The error message is not necessary, but helps with tracability of error logs.
This is also valid.