+ 2
public class Program { public static void main(String[] args) { int x=8, y=2; System.out.println(y%x);
can anyone explain how the output of this code is 2?
3 odpowiedzi
+ 2
% gives the remainder of a division.
8%5 is 3, because 5 fits one time into 8, and then 3 will be left.
2%8: 8 fits zero times into 2, and 2 will be left over.
+ 2
Read about the modulo operator.
https://www.sololearn.com/learn/Java/2140/
+ 2
Thanks guys