answersLogoWhite

0

What is the use of throw statement?

User Avatar

Anonymous

13y ago
Updated: 8/20/2019

throws keyword/statement is basically used to handle exception in java.

throws keyword is used to handle "unchecked exceptions".

Example:

public void enterdata()throws IOException

{

BufferedReader inp=new BufferedReader(new InputStreamReader(System.in));

int i=Integer.parseInt(inp.readLine());

}

Now after the enterdata function we have used throws keyword because the"readLine" method throws an unchecked exception ie., IOException during user input which cannot be handled by try catch block.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Throws statement in java?

throw new Throwable(); or throw new Error("Danger will Robinson!"); or throw new NullPointerException(); etc.


What is the difference between a declarative statement and an imperative statement?

In a declarative statement, you initialize the object. But in an imperative statement, you use a preexisting statement and use it.


What is the difference between 'switch' statement and 'if' statement?

we can use switch statement in multiple time but in if statement we can not use multiple time


Does a guy like you if he told you that he thought girls just use him and throw him to the curb?

This statement alone is not an indication one way or another that the boy likes you, at least not for anything more than a friend.


How can you access the value throw an array?

You cannot throw an array, only exceptions can be thrown. You access the thrown exception by catching it in a catch clause of a try...catch statement.


Can a continue statement be used in a switch statement?

If you have a loop in your switch statement or around your switch statement, you can use the continue statement in that. You cannot use a continue statement outside of a loop (do, for, or while).


What argumentative statement is a claim of value?

its is irresponsible to throw away uneaten food.-Apex


What is the origin of the idiom what can sorry do?

Sorry is a passive statement and refers to events that have past and so can not really do anything. It is a retort by someone who is upset to throw the statement back in the face of the apologiser.


What was jesus statement that proved that the woman was forgiven?

he said, if anyone of you is without sin, let him be the first to throw a stone at her


What does Statement of topic mean when doing a sciences project?

statment means wat to do nd throw pics of dicks


How do you use throw as a noun?

"Throw" as a noun refers to an act of throwing something. For example, you can make a long throw in baseball or a quick throw in basketball.


How do you use hammer throw in sd vs raw?

hold b when your about to throw them