I am trying to display a message after entering a series of numbers in an array and I am trying to print the array after the array limit is exceeded. The input in the array is working fine but displaying the messages after the array limit is exceeded is not working
import java.util.Scanner;
public class Array
{
public static void main (String[] args)
{
int i;
Scanner input= new Scanner(System.in);
int[] values = new int[10];
{
System.out.print("please insert a value : " );
for( i = 0 ;i < values.length; i++)
{
try
{
values[i] = input.nextInt();
}
catch (Exception e)
{
System.out.println("The value you have input is not a valid integer");
}
}
if (i> values.length)
{
System.out.println("Array limit exceeded");
for(i =0 ;i<values.length ; i++)
{
System.out.println(values[i]);
}
}
}
}
}
ifcondition. When you exit the loop,i = values.length.