If you want to test Java code and don’t have access to a development environment, you can still use a public service like ideone.com. I did that for you over here. Your program prints
y is:1
y is:2
y is:3
y is:4
y is:5
y is:6
y is:7
y is:8
y is:9
solved Result of x % 10 in Java [closed]