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 2 of 2

Thread: Why it is showing error??

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why it is showing error??

    Can any one please explain me why the statement given below is showing error.

    public static void main(String args[]){
    try{
    }
    catch(IOException t){ // line 4
    }
    }

    This code is showing error that, unreachable catch block. But this error wont be there if I am handling any other exception. The code given below is not showing any error at line 4.

    public static void main(String args[]){
    try{
    }
    catch(Exception t){ // line 4
    }
    }

    Can any one please explain it to me why this is happening.

    Thanks in advance..


  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    3
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why it is showing error??

    I think it's because you don't have any code that might throw an IO exception within try
    whereas Exception just covers everything

Similar Threads

  1. Showing JPanel error
    By Fermen in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 20th, 2011, 12:12 PM
  2. JTextBox not showing?
    By minime12358 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 14th, 2011, 08:02 AM
  3. Label not showing up.
    By joshft91 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 1st, 2011, 03:36 PM
  4. showMessageDialog is not showing!
    By jonathan920 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 27th, 2010, 04:14 AM
  5. Showing a picture in a GUI
    By joachim89 in forum AWT / Java Swing
    Replies: 1
    Last Post: February 15th, 2010, 02:42 PM