How does Karel run without “main” method?

前端 未结 5 1691
臣服心动
臣服心动 2021-01-21 20:34

I was wondering in the program like Karel the Robot runs because it does not used main() method. Instead it used run() method:

import stanford.karel.Karel;

publ         


        
5条回答
  •  耶瑟儿~
    2021-01-21 20:55

    The actual main method is somewhere else. For example, in the KarelRunner class. When java executes the program, it's actually executing the main method in the runner class. Your own run method is called from that runner code.

提交回复
热议问题