Hey guys, I am getting AIOB Exception(i know why this exception occurs, also i know i can handle them) but in my code i cant figure out why is it occurring.
Thanks for Any and Every Help.
And any critics are highly encouraged regarding the way i code and any(even slightest) improvement,that u can help me with.
Problem Statement:
Code:
import java.util.Scanner;
class Array
{
int i,fls=0;// variable as a flag to check if an array is beautiful or not.
static int size=new Scanner(System.in).nextInt();
static int[] array = new int[size];
public void getArray()
{
for (i=0;i<array.length;i++)
{
array[i]=new Scanner(System.in).nextInt();
}
primaryOp();
}
void primaryOp()
{
if(fls==0)
{
for(i=0;i<array.length;i++)
{
for(int j=1;j<array.length;j++)
{
scanArray(array[i],array[j]);
}
}
System.out.println("yes");
}
else
System.out.println("no");
}
boolean scanArray(int x, int y)
{
for(i=0;i<array.length;i++)
{
if(array[i]==(x*y))
{
return true;
}
}
fls++;
return false;
}
}
class BeautifulArrays
{
public static void main(String[] args)
{
new Array().getArray();
}
}