Question: Write a recursive method printArray that displays all the elements in an array of integers, separated by spaces. Here is the template public class Print

Write a recursive method printArray that displays all the elements in an array of integers, separated by spaces.
Here is the template
public class Print {
// call helper function to do work
public static void printArray( int[] array )
{
printArrayHelper( array, 0 );
System.out.println(); // add ending newline
}
// recursively print array
private static void printArrayHelper( int[] array, int startIndex )
{
// code goes here
}
// initializes values
public static void main( String args[] )
{
int array[] = { 8, 22, 88, 34, 84, 21, 94 };
System.out.print( "Array is: " );
printArray( array ); // print array
}
}

Step by Step Solution

3.36 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Print call helper function to do work public static void printArray int array printAr... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

1013-C-S-O-S (895).docx

120 KBs Word File

Students Have Also Explored These Related Operating System Questions!