This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
You don't need to use a loop. Assuming the "number" is infact a String (which I'm infering by preethi Ayyappan saying they can get the last 4 digits with substring); the String class has a substring method that takes a begin and end index. Just use that.