How can “while (i == i) ;” be a non-infinite loop in a single threaded application?

前端 未结 12 1102
甜味超标
甜味超标 2020-12-04 09:41

I just got a question that I can\'t answer.

Suppose you have this loop definition in Java:

while (i == i) ;

What is the type of

12条回答
  •  失恋的感觉
    2020-12-04 10:32

    The value of i is then Invalid. "Not a Number".

    After some googling, i found out that you CAN have NaN ( Not a Number ) in Java! So, a Float Pointing number is the Data Type and the Value is NaN. See here

提交回复
热议问题