What values will variables x and i finally have:

public class Main {
    public static strictfp void main(String...args) {
        int i = 0;
        for(double x = 0 ; x != 13.08 ; x += 0.12) {
The loop will run infinitely. The value of variable x will never become exactly 13.08 because of accuracy problems in floating-point operations. (Value 0.12 can't be precisely represented as a double, it will be represented approximately as 0.11999999... and so on). Correct condition would be: x <=13.08.

Слідкуй за CodeGalaxy

Мобільний додаток Beta

Get it on Google Play
Зворотній Зв’язок
Продовжуйте вивчати
тести з Java
Зареєструйся Зараз
або Підпишись на майбутні тести