Question: HI, i'm trying to get this program to find the max value of the array in the maxelement method, currently it works but only prints

HI, i'm trying to get this program to find the max value of the array in the maxelement method, currently it works but only prints "0". The recursion works as it should.

public class Recursion { public static boolean isMember(int[] array, int value) { if(array.length == 0) return false; if(array[0] == value) return true; int[] array2 = new int[array.length-1]; System.arraycopy(array,1,array2,0,array2.length); return isMember(array2, value); } public static void main (String[] args) throws java.lang.Exception { int[] array = new int[1000]; Scanner scanner = new Scanner(System.in); Scanner scanner1 = new Scanner(System.in); Scanner scanner2 = new Scanner(System.in); int range,number; System.out.println("Please enter the size of your array "); range=scanner.nextInt(); for (int i=0;i

public static void maxElement(int[] args){ int len = args.length; int [] array = new int [len]; for(int i=0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!