dimanche 27 septembre 2020

Why is assert passing all test cases when it shouldnt

public class Main {
public static void main(String args[]) {
    sumArray(8);
}

public static int sumArray(int nums){
   assert nums == 5;
   return nums;
}

}

Hi I was just wondering, when i pass a number that is not equal to 5, why doesnt the compiler throw any errors, since I am asserting that nums is equal to 5?

Aucun commentaire:

Enregistrer un commentaire