private static void BinToDec(String str) { int p=0,m=0; for(int i=str.length()-1;i>=0;i--){ char c = str.charAt(i); int a = Integer.parseInt(""+c); p=p+(int)(a*Math.pow(2, m)); m++; } System.out.println(p); }