```
button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            String output = "";
            char[] input = textArea.getText().toUpperCase().toCharArray();
            int index;

            for (int i = 0; i < input.length; i++) {
                if(input[i] != ' ') {
                    index = Arrays.asList(russian).indexOf(input[i]);
                    output += codeMorse[index] + " ";
                }
            }

            textArea.setText(output);
            button.setText("Конвертировано!");
        }
    });

```

//arrays

```
    char[] russian = new char[]{'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ж', 'З', 'И',
                            'Й', 'К', 'Л', 'М', 'Н', 'О', 'П', 'Р', 'С',
                            'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ы', 'Ь',//41
                            'Э', 'Ю', 'Я', '1', '2', '3', '4', '5', '6', '7',
                            '8', '9', '0' };

String[] codeMorse = new String[] { "*–", "–***", "*––", "––*",
                                    "–**", "*", "***–", "––**",
                                    "**", "*–––", "–*–", "*–**", //41
                                    "––", "–*", "–––", "*––*",
                                    "*–*", "***", "–", "**–",
                                    "**–*", "****", "–*–*",
                                    "–––*", "––––", "−−*−",
                                    "−*−−", "−**−", "**−**",
                                    "**−−", "*−*−", "*−−−−",
                                    "**−−−", "***−−", "****−",
                                    "*****", "−****", "−−***",
                                    "−−−**", "−−−−*", "−−−−−" };

```

//input value is "привет"

this code throws java.lang.ArrayIndexOutOfBoundsException: -1 exception. Both arrays in the same length. I think it throws due to indexOf, but I dont know how to change it.