Практика

This commit is contained in:
Евгений
2026-06-26 18:08:01 +03:00
parent d36d4542b0
commit 28dc8157b5
2 changed files with 17 additions and 10 deletions
+3
View File
@@ -0,0 +1,3 @@
enum Status {
SUCCESS, ERROR, WARNING
}
+14 -10
View File
@@ -4,16 +4,20 @@ import java.util.Scanner;
public class TaskDemo { public class TaskDemo {
public static void main(String[] args) { public static void main(String[] args) {
String[] words = {"код", "Програмирование", "джава"}; Status[] statuses = new Status[]{Status.SUCCESS, Status.ERROR, Status.WARNING};
System.out.println(findLongestWorld(words)); System.out.println(Array(statuses));
}
public static int Array(Status[] arr) {
int count = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] == Status.ERROR) {
count++;
}
}
return count;
} }
public static String findLongestWorld (String[] world) {
String longest = world[0];
for (int i = 1; i < world.length; i++) {
if (longest.length() < world[i].length()) {
longest = world[i];
}
} return longest;
}
} }