Skip to content

Commit

Permalink
added-java-4
Browse files Browse the repository at this point in the history
  • Loading branch information
rajjitlai authored Oct 13, 2024
1 parent 6c16b29 commit d34ea2c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Java/Practical/UnderAge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// File: UnderAge.java
class UnderAge extends Exception {
private int age;

// Constructor to initialize age
public UnderAge(int age) {
this.age = age;
}

// Override toString() to display custom message with age value
@Override
public String toString() {
return "Under Age: " + age;
}
}

0 comments on commit d34ea2c

Please sign in to comment.