I am trying to write a recursive method that prints out each index of an array. My Hand class represents a hand of five cards, using a Card[] cards of length 5. Below is my method so far. It works but is there a better way to do this instead of having an integer parameter of the index to start from? Please help.
public static void printHandForward (Hand hand, int index) {
if(index == hand.cards.length) {
return;
}
else {
Card.printCard(hand.cards[index]);
index++;
printHandForward(hand, index);
}
}