From d36d4542b0965f848d6800538a4ab07010e7cca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D0=B9?= Date: Thu, 25 Jun 2026 16:40:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=BA=D1=82=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TaskDemo.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/TaskDemo.java b/src/TaskDemo.java index 8474132..a135644 100644 --- a/src/TaskDemo.java +++ b/src/TaskDemo.java @@ -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; } }