lundi 11 novembre 2019

Why is Math.abs() returning 25 and saying no explicit return value?

I'm a bit confused about the math.abs() function. I need to debug this code but I somehow can't find the problem. It always says "no explicit return value" when I try to println() the result.

public class Test {

public static void main(String[] args) {

    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            if (Math.abs(i - 25) + Math.abs(j - 25) > 25) {
                System.out.println(" ");

            } else {
                System.out.println("+");
            }
        }
        System.out.println();
    }

}

}

I expect the program to output " " when the result of math.abs() is higher than 25 and "+" when it's lower than 25.

Aucun commentaire:

Enregistrer un commentaire