Question: Determine and explain the output from the following code: public class MyClass { public static void main(String args[]) { int [] a = new int
Determine and explain the output from the following code:
public class MyClass { public static void main(String args[]) { int [] a = new int [10]; int[] b = new int [10]; a [3] =7; b[3] =7; System.out.println(a.equals(b)); } }
I am getting a false output. Which I believe is incorrect and it should be true? I understand we are not using inheritance, but it seems that the code is placing the number 7 in the same place in both arrays, which should make it equal? Or must you have something like a=b in order for it to be equal?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
