我只是出于好奇而写了这两行:
public static void main(String[] args) throws InterruptedException {
Object obj = new ArrayList<String>().add("Some text");
System.out.println("output : " + obj.toString());
}
Run Code Online (Sandbox Code Playgroud)
由于Object类是所有内容的超类,因此该代码可以正确编译.但是当我运行它时,它会输出为:
output : true
Run Code Online (Sandbox Code Playgroud)
可能的原因是什么?