Java: Passing the same objects to each others constructor

前端 未结 6 2266
粉色の甜心
粉色の甜心 2021-01-21 10:56

Evening everyone.

I seem to have hit an odd problem when trying to pass an object to another objects constructor who\'s constructor also relies on the object it\'s being

6条回答
  •  时光说笑
    2021-01-21 11:20

    Maybe if you declare first

    WebPanel webPanel = new WebPanel(myToolBar);
    

    and then

    ToolBar myToolBar = new ToolBar(webPanel);
    

    The object must exist first to be passed.

提交回复
热议问题