I don't understand some example in Java.
public class Pair {
private int a;
private int b;
public Pair(){
}
public Pair(int x, int y) {
a = x;
b = y;
}
}
Second class
public class First extends Pair {
public First(int x, int y) {
super(x,y);
}
public static void main(String[] args) {
Pair pair = new Pair(10,11);
String s = "It is equal " + pair;
System.out.println(pair);
}
}
Because it's used concatenation of strings, automatically it will be called method toString() from class Pair,
so the result should be: "It is equal (10,11)".
It prints me location in memory why?
Maybe I should call method like:
public void show(){
System.out.println(a + "" + b);
}
However in example there isn't method show(), there is only String s like above.