i read that a method that is is using throws clause must be mentioned in the try and catch block.So when we use "throws IOException" in the following program why dont we use try and catch
import java.io.*;
class testthrows
{
public static void main(String args[]) //throws IOException
{
int i;
System.out.println("enter a number");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
i=Integer.parseInt(br.readLine());
System.out.println(i);
}
}
why dont we use try and catch here
akulkarni 0 Junior Poster
deepak.marur 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
akulkarni 0 Junior Poster
akulkarni 0 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.