Datasets:
ArXiv:
License:
Stack-Repo / data /train /akash-coded /FSD_Java /Lesson-3 /Exception Handling /Examples /CustomExceptionExample.java
Download data/train/akash-coded/FSD_Java/Lesson-3/Exception Handling/Examples/CustomExceptionExample.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 719 Bytes
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception%20Handling/Examples/CustomExceptionExample.java
- Command line
-
hf download 'hf://datasets/RepoFusion/Stack-Repo@bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception Handling/Examples/CustomExceptionExample.java'
-
curl -L -o CustomExceptionExample.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception%20Handling/Examples/CustomExceptionExample.java
719 Bytes
| class InvalidAgeException extends Exception { | |
| /** | |
| * Generated seialID | |
| */ | |
| private static final long serialVersionUID = -2714273560914952041L; | |
| InvalidAgeException(String s) { | |
| super(s); | |
| } | |
| } | |
| public class CustomExceptionExample { | |
| static void validate(int age) throws InvalidAgeException { | |
| if (age < 18) | |
| throw new InvalidAgeException("not valid"); | |
| else | |
| System.out.println("welcome to vote"); | |
| } | |
| public static void main(String args[]) { | |
| try { | |
| validate(13); | |
| } catch (Exception m) { | |
| System.out.println("Exception occured: " + m); | |
| } | |
| System.out.println("rest of the code..."); | |
| } | |
| } | |