javabinarystream

Unable to convert binary string to integer despite using parseInt in java


i want to get the integer i.e decimal number corresponding to the binary string nc. However this does not happen despite using parseInt(). for eg if nc="11000101" then edcode is also having the same value instead of giving me the decimal representation of nc. Can anyone please help

String codest="11010101";
char[] codear=codest.toCharArray();
codear[4]=codear[5];
String nc= new String(codear);
int edcode=Integer.parseInt(nc);

Solution

  • int edcode=Integer.parseInt(nc, 2); This will work