I have some confusion on the modulus operator, modulus gives the remainder as the output. so why is it different for the below scenario?
public class ModulusTest{
public static void main(String[] args) {
System.out.println(" 7/10 : " + 7/10 );//0.7
System.out.println(" 7%10 : " + 7%10 ); //0
System.out.println(" 5/2 : " + 5/2 );//2
System.out.println(" 5%2 : " + 5%2 );//1
}
}
The output i was expecting is as i kept in the comments on each line of the print statements in the above sample code. output:
7/10 : 0
7%10 : 7
5/2 : 2
5%2 : 1