ArrayTesterMax

ArrayTesterMax - } /** * Return the maximum number in an...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//Find maximum value in an array using a method. / import java.util.Scanner; i public class ArrayTesterMax { public static void main (String [] args) { int[] numArray = {-6, 7, 1, 3, -7, -10, 0, -4, 10}; int maxInArray = findMax(numArray); System.out.println("Maximum in array is " + maxInArray);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } /** * Return the maximum number in an array. */ public static int findMax(int intArray) { int max = intArray[0]; for(int i = 1; i < intArray.length; i++) { if(intArray[i] > max) max = intArray[i]; } return max; } }...
View Full Document

Ask a homework question - tutors are online