lr13 -> task_1 -> e1-e14
This commit is contained in:
14
lr13/task_1/e1.java
Normal file
14
lr13/task_1/e1.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e1 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new RuntimeException("Непроверяемая ошибка");
|
||||
} catch (RuntimeException e) { // исключение перехвачено
|
||||
System.out.println("1 " + e); // исключение обработано
|
||||
}
|
||||
System.out.println("2");
|
||||
}
|
||||
|
||||
}
|
||||
17
lr13/task_1/e10.java
Normal file
17
lr13/task_1/e10.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e10 {
|
||||
public static int m() {
|
||||
try {
|
||||
System.out.println("0");
|
||||
return 15;
|
||||
} finally {
|
||||
System.out.println("1");
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(m());
|
||||
}
|
||||
}
|
||||
15
lr13/task_1/e11.java
Normal file
15
lr13/task_1/e11.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e11 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new NullPointerException("ошибка");
|
||||
} catch (NullPointerException e) {
|
||||
System.out.println("1");
|
||||
} finally {
|
||||
System.out.println("2");
|
||||
}
|
||||
System.out.println("3");
|
||||
}
|
||||
}
|
||||
20
lr13/task_1/e12.java
Normal file
20
lr13/task_1/e12.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e12 {
|
||||
public static void m(String str, double chislo) {
|
||||
try {
|
||||
if (str == null) {
|
||||
throw new IllegalArgumentException("Строка введена неверно");
|
||||
}
|
||||
if (chislo > 0.001) {
|
||||
throw new IllegalArgumentException("Неверное число");
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.out.println("Error: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
m(null, 0.000001);
|
||||
}
|
||||
}
|
||||
17
lr13/task_1/e13.java
Normal file
17
lr13/task_1/e13.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e13 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
int l = args.length;
|
||||
System.out.println("размер массива = " + l);
|
||||
|
||||
int h = 10 / l;
|
||||
args[l + 1] = "10";
|
||||
} catch (ArithmeticException e) {
|
||||
System.out.println("Деление на ноль");
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
System.out.println("Индекс не существует");
|
||||
}
|
||||
}
|
||||
}
|
||||
17
lr13/task_1/e14.java
Normal file
17
lr13/task_1/e14.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e14 {
|
||||
public static void m(int x) throws ArithmeticException {
|
||||
int h = 10 / x;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
int l = args.length;
|
||||
System.out.println("размер массива = " + l);
|
||||
m(l);
|
||||
} catch (ArithmeticException e) {
|
||||
System.out.println("Ошибка: Деление на ноль");
|
||||
}
|
||||
}
|
||||
}
|
||||
14
lr13/task_1/e2.java
Normal file
14
lr13/task_1/e2.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e2 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new RuntimeException("Непроверяемая ошибка");
|
||||
// System.out.println("1");
|
||||
} catch (Exception e) {
|
||||
System.out.println("2 " + e);
|
||||
}
|
||||
System.out.println("3");
|
||||
}
|
||||
}
|
||||
17
lr13/task_1/e3.java
Normal file
17
lr13/task_1/e3.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e3 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new RuntimeException("ошибка");
|
||||
} catch (NullPointerException e) {
|
||||
System.out.println("1");
|
||||
} catch (RuntimeException e) {
|
||||
System.out.println("2");
|
||||
} catch (Exception e) {
|
||||
System.out.println("3");
|
||||
}
|
||||
System.out.println("4");
|
||||
}
|
||||
}
|
||||
17
lr13/task_1/e4.java
Normal file
17
lr13/task_1/e4.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e4 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new RuntimeException("ошибка");
|
||||
} catch (NullPointerException e) {
|
||||
System.out.println("1");
|
||||
} catch (Exception e) {
|
||||
System.out.println("2");
|
||||
} catch (Error e) {
|
||||
System.out.println("3");
|
||||
}
|
||||
System.out.println("4");
|
||||
}
|
||||
}
|
||||
13
lr13/task_1/e5.java
Normal file
13
lr13/task_1/e5.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e5 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new RuntimeException("ошибка");
|
||||
} catch (RuntimeException e) {
|
||||
System.out.println("1");
|
||||
}
|
||||
System.out.println("2");
|
||||
}
|
||||
}
|
||||
15
lr13/task_1/e6.java
Normal file
15
lr13/task_1/e6.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e6 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new NullPointerException("ошибка");
|
||||
} catch (ArithmeticException e) {
|
||||
System.out.println("1");
|
||||
} catch (Exception e) {
|
||||
System.out.println("2");
|
||||
}
|
||||
System.out.println("4");
|
||||
}
|
||||
}
|
||||
18
lr13/task_1/e7.java
Normal file
18
lr13/task_1/e7.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e7 {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new NullPointerException("ошибка");
|
||||
} catch (NullPointerException e) {
|
||||
System.out.println("1");
|
||||
try {
|
||||
throw new ArithmeticException();
|
||||
} catch (ArithmeticException e2) {
|
||||
System.out.println("2");
|
||||
}
|
||||
}
|
||||
System.out.println("3");
|
||||
}
|
||||
}
|
||||
19
lr13/task_1/e8.java
Normal file
19
lr13/task_1/e8.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e8 {
|
||||
public static int m() {
|
||||
try {
|
||||
System.out.println("0");
|
||||
throw new RuntimeException();
|
||||
} catch (RuntimeException e) {
|
||||
System.out.println("1");
|
||||
} finally {
|
||||
System.out.println("2");
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(m());
|
||||
}
|
||||
}
|
||||
17
lr13/task_1/e9.java
Normal file
17
lr13/task_1/e9.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package lr13.task_1;
|
||||
|
||||
public class e9 {
|
||||
public static int m() {
|
||||
try {
|
||||
System.out.println("0");
|
||||
return 55; // выход из метода
|
||||
} finally {
|
||||
System.out.println("1");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(m());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user