Hi all,
Does anyone know why i keep getting illegal start of type when i type System.out.println("The Largest Number is " + maxValue(numbers));
when i put // infront of it as a comment it compiles fine although i do not get the output.
import java.util.Scanner; import java.io.*; import java.io.IOException; import java.util.*; import java.util.Arrays; public class arrayNum { public static void main (String args[]) throws IOException{ Scanner input = new Scanner(System.in); int array[] = new int[5]; int count=0; int numbers; System.out.println("Please enter 5 numbers"); { while (count < 5) { //the input you get must be store in the array array[count] = input.nextInt(); count++; } } } System.out.println("The Largest Number is " + maxValue(numbers)); public static int getmaxValue(int[] numbers) { int maxValue = numbers[1]; for(int i=1;i<numbers.length;i++) { if(numbers[i] < maxValue) { maxValue = numbers[i]; } } return maxValue; } // int max = array[5]; // for(int i = 1; i < 5; i++) // { // if(array[i] > max) // { // max = array[i]; // } // } // print the value instead of printing // return max; }
Your help is greatly appreciated!