You reset the decValue every time though the loop, rather than incrementing it:



decValue += Math.pow(2, binaryString.length()- i );


Also, inspect your loops closely. You are getting...