package test2;
public class StringLargeException {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Asked
Active
Viewed 135 times
-2

Derlin
- 9,572
- 2
- 32
- 53

Srini Malhotra
- 11
- 1
- 3
-
please follow the package naming conventions by reading https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html – 0xDEADBEEF Apr 12 '17 at 08:36
2 Answers
0
Simple; put the following into some Test.java ... compile and run.
class MyException extends Exception {
MyException(String message) { super(message); }
}
public static void main(String args[]) throws Exception {
throw new MyException("you didnt see this one coming");
}

GhostCat
- 137,827
- 25
- 176
- 248
0
- make a class A that extends From Exception class
- make a constructor that you can pass a message to the class
- then when you want to throw the exception just type
throw new A("Message");

Basil Battikhi
- 2,638
- 1
- 18
- 34