Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Java Exceptions

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Converting MM/DD to 17 January

    Hi there,

    Figured out the other part...

    Now this part..

    I have to convert MM/DD to word format, eg:

    1/17 to 17 January

    Is there an easier way to do this than if/switch/etc?
    Last edited by Vinceisg0d; March 2nd, 2010 at 06:48 PM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Java Exceptions

    To create your own exception, extend Exception or RuntimeException (depending on whether you want a check or an uncheck exception)

    public class MyException extends Exception
    {}// really no code needed, it's all in the Exception class

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java Exceptions

    here simple program.
    1. public class Excep16 {
    public static void main(String[] args) {
    try{
    for(int cnt = 0; cnt < 5; cnt++){
    if(cnt == 5) throw new MyException("number is 3");
    }
    }
    catch(MyException e){
    System.out.println("In exception handler, "+ "get the message\n" + e.getMessage());
    }
    System.out.println("Out of catch block");
    }

    }
    2.
    public class MyException extends Exception{

    MyException(String message){
    super(message);
    }

    }

Similar Threads

  1. Use of Exceptions and Methods of The String Class
    By cagataylina in forum Exceptions
    Replies: 1
    Last Post: April 26th, 2011, 01:56 AM
  2. Replies: 0
    Last Post: December 12th, 2009, 09:09 PM
  3. Replies: 2
    Last Post: November 19th, 2009, 10:55 PM