Hi i've been trying to figure out where to find the biggest number in an array. I know how to find the biggest number but i need to find out where the biggest number is, like which row or whatever it's in.
import java.util.Scanner; public class array { public static void main (String args[]) { Scanner keyboard = new Scanner(System.in); int r[] = new int[50]; int n=0; int x, bigSoFar; System.out.print("Enter list: "); x = keyboard.nextInt(); while( x!= -999); { r[n] = x; n++; x = keyboard.nextInt(); } for(int k = 0; k < n; k++) if(r[k]> bigSoFar) { bigSoFar = r[k]; } System.out.println(r[k]); } }
Although first i'm having trouble trying to get my first code to work, i keep getting this error
array.java:34: error: cannot find symbol
System.out.println(r[k]);
^
symbol: variable k
location: class array
1 error