How does Java choose which constructor to use?

后端 未结 2 1444
甜味超标
甜味超标 2020-12-20 14:26

I am not able to understand the output of the following program.

public class Confusing {

    private Confusing(Object o) {
        System.out.println(\"Obj         


        
2条回答
  •  囚心锁ツ
    2020-12-20 15:10

    The challenge of compiling dynamically typed languages is how to implement a runtime system that can choose the most appropriate implementation of a method or function — after the program has been compiled. Treating all variables as objects of Object type would not work efficiently.

    Hence, choosing the specific one over Object.

提交回复
热议问题