Bloch talked about many Java puzzles. Today I will share them with you.
0-cycle subject
Please write a variable declaration and place it before the following loop to make this loop an infinite loop.
For (INT I = start; I <= start + 1; I ++ ){
}
Here, start is an undefined variable. We need to define it.
If you are familiar with int, you may get the correct answer:
Int start = integer. max_value-1;
Why? Haha, because Int. max_value + 1 = int. Min-value.
You need to consider the following. # ^ _ ^ #
1 loop Operator
What kind of statement can make the following loop infinite?
While (I = I + 1 ){
}
2. The Bride of the loop
Provide an I statement so that the following loop is an infinite loop.
While (I! = I ){
}
3. The love of the loop Operator
Provide an I statement so that the following loop is an infinite loop.
While (I! = I + 0 ){
}
4. The ghost of the loop
Provide an I statement so that the following loop is an infinite loop.
While (I! = 0 ){
I >>>= 1;
}
5. cursing the loop
Provide declarations on I and j so that the following loop is an infinite loop.
While (I <= J & J <= I & I! = J ){
}
6. The person in the loop met the prodigal person.
Provide an I statement so that the following loop is an infinite loop.
While (I! = 0 & I =-I ){
}