How does chained methods execute in java?

前端 未结 3 1713
清酒与你
清酒与你 2020-12-20 06:29

Here is my code :

result = method1().method2().method3();

I would like to know the execution hierarchy of the above code/

3条回答
  •  天涯浪人
    2020-12-20 07:16

    Same as this:

    result1 = method1();
    result2 = result1.method2();
    result = result2.method3();
    

提交回复
热议问题