Can anyone tell me whats wrong in this method and why it gives a nullpointerException ?
public boolean check(){
Scanner scan = new Scanner(System.in);
int[] arr1 = new int []{1,2,3};
int[] arr2 = new int[]{};
for(int i = 0;i<arr1.length;i++)
{
System.out.println("Enter numbers to check");
arr2[i] = scan.nextInt();
}
if(arr1 == arr2)
return true;
return false;
}
1 Answer