September 09, 2010, 01:31:32 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Custom exception class demo  (Read 1414 times)
0 Members and 1 Guest are viewing this topic.
deAppel
Favorite member
Member
*

Reputation: 0
HappyFace plants one on you
Offline Offline
Posts: 45
Referrals: 0

Awards
« on: June 18, 2007, 06:58:11 PM »

Here's a demo to create a custom exception class.

Code
GeSHi (java):
  1. /*--------------------------------------------------------------------------
  2. // Author List:
  3. //      deAppel <Creator>
  4. //
  5. // Description:
  6. // Create a custom exception class. Part 1/2
  7. //
  8. // Environment:
  9. //      This software was developed using Eclipse and Java 1.6
  10. //
  11. // Copyright Information:
  12. //      Copyright (C) 2007      <Institution><None>
  13. // Ark de Appel www.engineeringserver.com
  14. //
  15. //----------------------------------------------------------------------*/
  16.  
  17. public class ExceptionDemo{
  18. public static void main(String[] args){
  19. ExceptionDemo ED = new ExceptionDemo();
  20. ED.oopsExcepton(12);
  21. }
  22.  
  23. public void oopsExcepton(int i){
  24. if (i < 18){
  25. try {
  26. throw new ExceptionDemoClass("Age below 18");
  27. } catch (ExceptionDemoClass e) {
  28. e.printStackTrace();
  29. }
  30. }
  31. if (i > 18){
  32. System.out.println("Age 18+");
  33. }
  34. }
  35. }
  36.  
Created by GeSHI 1.0.7.20

Code
GeSHi (java):
  1.  
  2.  
  3. /*--------------------------------------------------------------------------
  4. // Author List:
  5. //      deAppel <Creator>
  6. //
  7. // Description:
  8. // Create a custom exception class. Part 2/2
  9. //
  10. // Environment:
  11. //      This software was developed using Eclipse and Java 1.6
  12. //
  13. // Copyright Information:
  14. //      Copyright (C) 2007      <Institution><None>
  15. // Ark de Appel www.engineeringserver.com
  16. //
  17. //----------------------------------------------------------------------*/
  18.  
  19. public class ExceptionDemoClass extends Exception{
  20.  
  21. public ExceptionDemoClass(){
  22. }
  23.  
  24. public ExceptionDemoClass(String msg){
  25. super(msg);
  26. }
  27. }
  28.  
  29.  
Created by GeSHI 1.0.7.20
Logged

Earn $0.04 or more for each search you make! http://www.myhpf.co.uk/apply001.asp?Friend=77889

If you need homework help, just post your assignment and i'll code it before your deadline =) i'll provide you "t3h c0d3z" but only if you show me that you have done something and not just ask for me to write everything for you. Just tell us what the problem is and i'm sure we can fix it for you!

I was born into the Hakka lineage, A bloodline that
traces it's roots back to the original Han emperors of
China. During the rise of the 3 Kingdoms (China's
famous warring period), the Hans were overthrown
and exiled. Forced to flee, they headed south finding
refuge within the mountains of Guilin Province where
they lived under their new title, the Hakka and patiently
wait for their chance to return to the throne as the
Sons Of Heaven...
Javaforums.net :: a community about Java software development.
« on: June 18, 2007, 06:58:11 PM »

Your Ad Here
 Logged
gluk
Member
*

Reputation: 0
Offline Offline
Posts: 22
Referrals: 0

Awards
« Reply #1 on: April 21, 2009, 05:47:12 PM »

The solution for most of the Java related errors can be found at this site: Java errors and solutions.
« Last Edit: April 22, 2009, 12:46:29 PM by HappyFace » Logged
Javaforums.net :: a community about Java software development.
   

Your Ad Here
 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.245 seconds with 33 queries.

Google visited last this page Today at 03:45:08 AM