This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson06.task01; | |
/* Исключение при работе с числами | |
Перехватить исключение (и вывести его на экран), указав его тип, возникающее при выполнении кода: | |
int a = 42 / 0; | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) throws Exception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson06.task02; | |
/* Исключение при работе со строками | |
Перехватить исключение (и вывести его на экран), указав его тип, возникающее при выполнении кода: | |
String s = null; | |
String m = s.toLowerCase(); | |
*/ | |
public class Solution | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson06.task03; | |
/* Исключение при работе с массивами | |
Перехватить исключение (и вывести его на экран), указав его тип, возникающее при выполнении кода: | |
int[] m = new int[2]; | |
m[8] = 5; | |
*/ | |
public class Solution | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson06.task04; | |
import java.util.ArrayList; | |
/* Исключение при работе с коллекциями List | |
Перехватить исключение (и вывести его на экран), указав его тип, возникающее при выполнении кода: | |
ArrayList<String> list = new ArrayList<String>(); | |
String s = list.get(18); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson06.task05; | |
import java.util.HashMap; | |
/* Исключение при работе с коллекциями Map | |
Перехватить исключение (и вывести его на экран), указав его тип, возникающее при выполнении кода: | |
HashMap<String, String> map = new HashMap<String, String>(null); | |
map.put(null, null); | |
map.remove(null); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson08.task01; | |
import java.io.FileNotFoundException; | |
import java.net.URISyntaxException; | |
import java.util.HashMap; | |
/* Исключения | |
Есть метод, который выбрасывает два исключения, унаследованные от Exception, и два унаследованных от RuntimeException: | |
NullPointerException, ArithmeticException, FileNotFoundException, URISyntaxException. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson08.task02; | |
/* Перехватывание исключений | |
1. Есть три исключения последовательно унаследованные от Exception: | |
2. class Exception1 extends Exception | |
3. class Exception2 extends Exception1 | |
4. class Exception3 extends Exception2 | |
5. Есть метод, который описан так: | |
5.1. public static void method1() throws Exception1, Exception2, Exception3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson08.task03; | |
import java.io.CharConversionException; | |
import java.io.IOException; | |
import java.nio.file.FileSystemException; | |
/* Перехват выборочных исключений | |
1. Разберись, какие исключения бросает метод BEAN.methodThrowExceptions. | |
2. Метод processExceptions должен вызывать метод BEAN.methodThrowExceptions и обрабатывать исключения: | |
2.1. если возникло исключение FileSystemException, то логировать его (вызвать метод BEAN.log) и пробросить дальше |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson08.task04; | |
import java.io.IOException; | |
import java.rmi.RemoteException; | |
/* Перехват checked исключений | |
В методе processExceptions обработайте все checked исключения. | |
Нужно вывести на экран каждое возникшее checked исключение. | |
Можно использовать только один блок try.. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level09.lesson11.home02; | |
/* Обратный отсчёт от 10 до 0 | |
Написать в цикле обратный отсчёт от 10 до 0. Для задержки иcпользовать Thread.sleep(100); | |
Обернуть вызов sleep в try..catch. | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) |
OlderNewer