This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.

write a method to compute the sum of the digits in an integer public static int sumDigits(long n) sumDigits(234) returns 2+3+4=9 would someone help wiht this?

Hi fabio, welcome to the ranch. As others have pointed out, you won't get much help if you just ask people to write your homework for you. You will, however, gets LOTS of valuable and quality help with concepts and specific problems you might be having. If you are having problems with getting started with this specific method, I'd venture you're having trouble separating out the individual decimal digits. If you are trying a mathematical solution, that'd be painful because decimal is not a natural numbering system for computers. So as a hint, how could you somehow transform the incoming value in such a way that it would be easy to isolate the individual digits? hth, bear