import java.util.Arrays;
class B {
int i;
B(int i) {
this.i = i;
}
public String toString() {
return "i = " + this.i;
}
}
public class MainClass{
public static void main(String[] args) {
B [] x = new B[2];
x[0] = new B(90);
x[1] = new B(100);
B obj = new B(10);
System.out.println(obj);
System.out.println(x);//toString method of class B is not called here.
}
}
//When i printed obj the toString method of B class was called but when I tried to print x it was not called.Can anybody explain why!!!