public class ProductTest{
public static void main(String[] args){
Product pr=new Product();
System.out.println(pr); /// Product@hashcode
}
}
class Product{
}
I can understand the above output of Product@hashcode since println method internally uses valueOf method and converts it into the string.
But I cannot explain the behavior of output below,
public class ProductTest{
public static void main(String[] args){
Product pr=new Product();
String str=pr + "something";
System.out.println(str); // Product@hashcodesomething
}
}
class Product{
}
How can class instance and string literal be added together?
What am I missing?