Это метод, который я хочу изменить с «void» на «String».
public static void businessLogic(String[] words) {
for (String word : words) {
char[] arrayWordsInChar = word.toCharArray();
int wordLength = word.length();
for (int i = 0, j = wordLength - 1; i < j; ) {
if (!Character.isAlphabetic(arrayWordsInChar[i]))
i++;
else if (!Character.isAlphabetic(arrayWordsInChar[j]))
j--;
else
swapLetters(arrayWordsInChar, i++, j--);
}
System.out.print(arrayWordsInChar);
System.out.print(" ");
}
// possible return...
}
Когда я пытаюсь установить возвращаемое значение «arrayWordsInChar», IDEA не видит эту переменную ...
Еще немного кода:
public static void swapLetters(char[] arr, int i, int j) {
char tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
И Main.Class:
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] words = scanner.nextLine().split(" ");
businessLogic(words);
// System.out.println(businessLogic(words));
}
}