package test2;
public class StringLargeException {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Asked
Active
Viewed 111 times
-2
Derlin
- 9,003
- 2
- 25
- 47
Srini Malhotra
- 11
- 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
- 133,361
- 24
- 165
- 234
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,606
- 16
- 31