|
-
September 29th, 1999, 06:12 AM
#1
Exception Handling
I have written following code. When i compile it , it gives the error message
import java.lang.*;
import java.io.*;
import java.util.*;
public class Short
{
public static void main(String args[])
{
System.in.read();
}
}
Error message
Excpetion java.io.IOException must be caught
-
September 29th, 1999, 06:15 AM
#2
Re: Exception Handling
You must write the main like that:
public static void main(String args[])
{
try
{
System.in.read();
}
catch (IOException e)
{
}
}
-
September 29th, 1999, 06:28 AM
#3
Re: Exception Handling
Thanks Erbeere
I have a question for you
If any function declares as it throws exception
and when we use it in any code block ,
is it necessary that code block should be in
try {}
-
September 29th, 1999, 06:32 AM
#4
Re: Exception Handling
Yes
If a method throws an exception than you must set it in a try block and directly after that a catch block.
If a method throws more exceptions than one, you only set one try but more catch blocks.
For the beginning and if you speak German than it is the easiest if you will search for the Book "Java in 21 Tagen" there is everything explained really good but I don´t know if you´ll find this in English or another language
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|