Public static int findWordsEndingWithY(String[] arr) { int count = 0; for (int i = 0; i < ; i++) { if (arr[i].charAt(arr[i]/length()-1) == 'y') { count++; } } return count; } can you rewrite this code in String format?
a) Rewrite given code snippet in String format
b) Correct syntax errors in the code
c) Clarify loop conditions and logic
d) Ensure functionality of code for counting words ending with 'y'