How does Karel run without “main” method?

前端 未结 5 1686
臣服心动
臣服心动 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:42

    When you read all of those instructions, you will discover that the program being run by Karel is a small part of a larger system -- the larger system involves drawing the map, discovering logic errors, etc. You write things in run(), then you use one of the classes which actually runs the entire system, and one of THOSE calls run() on your program. Good luck.

提交回复
热议问题