I've added some statements to the original code,
The above code will generate output :
After a.x = 23 statement
a.x = 23
a1.x = 23
After a1.x = 0 statement
a.x = 0
a1.x = 0
true
x is static(class) variable, so there will be
only one copy of x which will be
shared by all the objects of class B. So it doesn't matter if you access x using any objects reference variable, it will be same as
B.x.
Here, equals() test will always be true for all the objects of class B.
hth.
[ March 16, 2008: Message edited by: Khushbu Ghodasara ]