Практика
This commit is contained in:
+10
-7
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user