// Demonstrates comparison and assignment of reference types
public class Array_Compare2
{
public static void main(String[] args)
{
int[] a = {1,1,1};
int[] b = {1,1,1};
if (a == b) System.out.println( "Same"); else System.out.println( "DIFF");
a = b;
if (a == b) System.out.println( "Same"); else System.out.println( "DIFF");
a[1] = 99;
if (a == b) System.out.println( "Same"); else System.out.println( "DIFF");
System.out.println(a[1]);
System.out.println(b[1]);
}
}
// Output below (what do you predict?):
// DIFF
// Same
// Same
// 99
// 99