Практика

This commit is contained in:
Евгений
2026-06-25 16:40:27 +03:00
parent 161fcf6aef
commit d36d4542b0
+10 -7
View File
@@ -1,16 +1,19 @@
import java.util.Arrays;
import java.util.Scanner; import java.util.Scanner;
public class TaskDemo { public class TaskDemo {
public static void main(String[] args) { public static void main(String[] args) {
String[] color = {"FFFFFF", "000000", "E7495B", "333333"}; String[] words = {"код", "Програмирование", "джава"};
System.out.println(findColor(color,"E7495B")); System.out.println(findLongestWorld(words));
} }
public static boolean findColor(String[] pallete, String target) { public static String findLongestWorld (String[] world) {
for (int i = 0; i < pallete.length; i++) { String longest = world[0];
if (pallete[i].equalsIgnoreCase(target)) { for (int i = 1; i < world.length; i++) {
return true; if (longest.length() < world[i].length()) {
longest = world[i];
} }
} return false; } return longest;
} }
} }