Files
freeCodeCamp/guide/russian/java/throws-keyword/index.md
2018-10-16 21:32:40 +05:30

32 lines
1004 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Throws
localeTitle: Броски
---
## бросает
Ключевое слово Java throw используется для объявления исключения. Он дает информацию программисту о том, что может возникнуть исключение, поэтому программисту лучше предоставить код обработки исключений, чтобы можно было поддерживать нормальный поток.
**_Пример:_**
```java
import java.io.IOException;
class Testthrows1{
void m()throws IOException{
throw new IOException("device error");//checked exception
}
void n()throws IOException{
m();
}
void p(){
try{
n();
}catch(Exception e){System.out.println("exception handled");}
}
public static void main(String args[]){
Testthrows1 obj=new Testthrows1();
obj.p();
System.out.println("normal flow...");
}
}
```