Write a program, when given an array of integers, it returns the biggest integer.
Can you please tell me what's wrong in this program??
import java.util.Scanner;
public class Arrayint {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int i,index,max;
int x;
int[] list=new int[x];
max=list[0];
System.out.println("Enter length of array: ");
x=input.nextInt();
System.out.println ("Enter values for Array:");
for (i=0;i<x;i++)
list[i]=input.nextInt();
for (i=1;i<list.length;i++)
{
if (max < list[i])
{
max=list[i];
}
}
index=max;
System.out.println("largest: "+index);
}
}
public class Arrayint {
public static void main(String[] args)
{
int list[]={3,7,6,1,9,96,2};
int i,index,max;
max=list[0];
for (i=1;i<list.length;i++)
{
if (max < list[i])
{
max=list[i];
}
}
index=max;
System.out.println("largest: "+index);
}
}