In this article we will discuss about “throw” keyword in Java. Usage of throw keyword is anti to exception handling that is we are raising exception and not handling it.
Let us take an example to understand this better.
As JRE and compiler doesn’t distinguish zero, positive and negative integers. So in any case if someone enter age as zero or negative value , it is violating business logic. In order to terminate the program while such conditions occurs , we are guiding JRE not to execute the program as the condition is not suitable from business perspective.