Практика

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;
public class TaskDemo {
public static void main(String[] args) {
String[] color = {"FFFFFF", "000000", "E7495B", "333333"};
System.out.println(findColor(color,"E7495B"));
String[] words = {"код", "Програмирование", "джава"};
System.out.println(findLongestWorld(words));
}
public static boolean findColor(String[] pallete, String target) {
for (int i = 0; i < pallete.length; i++) {
if (pallete[i].equalsIgnoreCase(target)) {
return true;
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 false;
} return longest;
}
}