Interview Question
Software Engineer Mobile Interview
-
LinkedInImplement Integer.parseInt from scratch
Interview Answers
3 Answers
▲
1
▼
to study for this interview I suggest rewriting all of the basic Java methods ;)
Anonymous on
▲
1
▼
can't u just parse char by char and use a bunch of shift operators and since ur just using charAt(i) to pick up a character u can use the same i and just raise it to the power of 10 and just or it with some bytes
not really! on
▲
0
▼
public static int parseInt(String stringToConvert) { int i =0,num=0; int isNeg = 1; int length = stringToConvert.length(); if(stringToConvert.charAt(0) =='-') { isNeg=-1; i=1; } while(i
Seluj on
Add Answers or Comments
To comment on this, Sign In or Sign Up.