How to make loop infinite with “x <= y && x >= y && x != y”?

前端 未结 4 824
南方客
南方客 2020-12-16 11:07

I had this interview question some years ago but I haven\'t found the answer yet.

What should be x and y to make a infinite loop?

while (x <= y&am         


        
4条回答
  •  猫巷女王i
    2020-12-16 11:38

    you have to create two Integer Objects, for example:

    Integer x = new Integer(2);
    Integer y = new Integer(2);
    

    Because x and y are Objects and no ordinal types, you get an infinite loop.

提交回复
热议问题