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; } }