Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PLIK: MyException.java
- import java.io.*;
- public class MyException extends Exception {
- public MyException() {
- }
- public string getMessage() {
- return „This is my message - something is wrong”;
- }
- }
- /* koniec pliku MyException.java ktory musisz zaincludować w pliku, ktory to rzuca
- Coś co rzuca:
- */
- Class coś throws MyException {
- public void rób_rzeczy() {
- if(something_is_wrong == true) {
- throw MyException();
- }
- }
- }
- /*
- coś co ma wyświetlić
- */
- try {
- mój_coś.rób_rzeczy();
- }
- Catch (MyException e1) { // mój_coś.rób_rzeczy() rzucił wyjątek.
- System.out.println(e1.getMessage);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement