Subject Android
Institute Daffodil International University 2013

The purpose of this type of questions is not to know that an engineer remembers piece by piece the entire code that performs parseInt() - who does it, I have never seen the

current code! -but to put him on thinking. Integer is a wrapper class around int. While a string cannot be translated directly into string, we can (character by character) access it and convert it into an integer.
This is an approximate version of what a candidate should answer.
- init some result with the value 0
- for each character in the string parameter do
result = result * 10
get the digit from the character
add the digit to the result
- return result

Login to post your comment.