throwing exceptions java
/* In this program we are checking the Student age
* if the student age<12 and weight <40 then our program
* should return that the student is not eligible for registration.
*/
public class ThrowExample {
static void checkEligibilty(int stuage, int stuweight){
if(stuage<12 && stuweight<40) {
throw new ArithmeticException("Student is not eligible for registration");
}
else {
System.out.println("Student Entry is Valid!!");
}
}
public static void main(String args[]){
System.out.println("Welcome to the Registration process!!");
checkEligibilty(10, 39);
System.out.println("Have a nice day..");
}
}
Also in Java:
- set password visible in android
- how to print something in java
- how to create a java jframe
- java bigdecimal compareto
- how to compare two maps in java
- spigot actionbar
- Enums injava
- bootstrap center text vertically
- java get current date without time
- alfred workflow
- set java
- full shutdown windows 10 cmd
- java hashmap put
- java double format
- java find if element of list in present in another list
- java repository sql find not in list
- how to create a circle in java
- java set example
- hashmap in java
- create jdbc connection in java
- how to pass parameters to xsl file
- stream java example
- recursive function for fibonacci series in java javascript
- string to double java