Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public static void testaaArvo(int i) throws PieniPoikkeus, SuuriPoikkeus {
  2. if (i < 5) {
  3. throw new PieniPoikkeus("Arvo oli alle 5.");
  4. } else if (i > 10) {
  5. throw new SuuriPoikkeus("Arvo oli yli 10.");
  6. }
  7. }
  8.  
  9. public static void tulostaVirheTeksti(Exception e) {
  10. System.out.println(e.getMessage());
  11. }
  12. }
  13.  
  14. class PieniPoikkeus extends Exception {
  15. public PieniPoikkeus(String msg) {
  16. super(msg);
  17. }
  18. }
  19.  
  20. class SuuriPoikkeus extends Exception {
  21. public SuuriPoikkeus(String msg) {
  22. super(msg);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement