Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions