I am new to Java and looking for code optimization techniques. This code is giving the expected output using two for loops and I want to reduce/eliminate the loops (if possible).
public static void main(String[] args) { String dummy = "Hello how are you"; String[] strArr = dummy.split(" "); for(int i=0; i < strArr.length;i++){ String word = strArr[i]; for(int j=word.length(); j > 0; j--){ System.out.print(word.charAt(j - 1)); } System.out.print(" "); } } Output: olleH woh era uoy
Please advice.