Good day to all! There was a problem with checking the array in the java programming language. Briefly: There is a variable for user input, there is an array, and there is an if branch, and yes .. There is a random object. The user enters the word: Hi (Must pass the if check) After checking the array, the function of displaying the message to the user is called (From the second array, this should be random);
- How to write an array? (And what would the code look like normally);
- How to make an array check in if? (I used equals (););
- How to display a random phrase from an array? (Specifying an array with a random variable does not work);
A piece of code (chopped):
String setscan = scans.nextLine();//Считывает ввод пользователя; setscan = setscan.replaceAll(" +", "");//Игнорирует пробелы при вводе; String[] dict_one = { "Добрый день", "Привет", "Здравствуй"}; Random rnd = new Random(); //Создаем новый объект класса Random; int rnds = rnd.nextInt(2); // Генерируем числа от 0 - 2; //Словарь 1, проверка - ответ; if (setscan.equals(dict_one)) { System.out.println(dict_one[rnds]); I will be very grateful! Notes: I'm new to the forum, just like in java;