I don't know much about Java, so you'll have to translate it to the form you need. Basically, you want to find the digits one by one and add to a sum.

Let n be your input number, m is a working variable, sum is the total you are looking for; all are positive integers.

m = n; sum = 0; while(m>0){sum+=m%10; m/=10}

Let n be your input number, m is a working variable, sum is the total you are looking for; all are positive integers.

m = n; sum = 0; while(m>0){sum+=m%10; m/=10}