Write a statement that calls the recursive method backwardsAlphabet() with param
ID: 3857962 • Letter: W
Question
Write a statement that calls the recursive method backwardsAlphabet() with parameter startingLetter. JAVA ONLY: please comment with only the 'your solution goes here' line! public class RecursiveCalls { public static void backwardsAlphabet(char currLetter) { if (currLetter == 'a') { System.out.println(currLetter); } else { System.out.print(currLetter + " "); backwardsAlphabet(--currLetter); } return; } public static void main (String [] args) { char startingLetter = '-'; startingLetter = 'z'; //Your solution goes here// return; } }
Explanation / Answer
"backwardsAlphabet(startingLetter);"
The above line would be sufficient if you just want pass a char value to the backwardsAlphabet method.
The other way you can do is
//here you are creating an object of the class named calls
RecursiveCalls calls = new RecursiveCalls();
//through the object you are passing the char value to the backwardsAlphabet method.
calls.backwardsAlphabet(startingLetter);
I hope this helps.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.