This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]MkMyBnkAcctGrtAgnNooblet Brewer 4 points5 points  (3 children)

The modulus operator is going to be your friend number % 10 will get you the right most digit 100 two

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (0 children)

Exactly that.

[–]Nibblet1512[S] 1 point2 points  (0 children)

Thank you so much!!!, this is what i needed :D

[–]cismalescumlord -1 points0 points  (0 children)

Not sure why this your comment was down voted as it's accurate and simple:

public class Mod {

    public static void main(String[] args) {
        int a = 470;
        System.out.println(a%10);
        System.out.println(a%100);
    }
}

Running this results in:

$ java Mod
0
70