package binarywa;
import java.util.*;
public class binaryadd {
public static void main(String args[])
{
Scanner scan=new Scanner(System.in);
String g=scan.next();
String s[]=g.split("");
int i,x=0;
for(i=s.length;i>0;i--)
{
x+=Integer.parseInt(s[i])*Math.pow(2,i);
}
}
}
Im trying to convert binary into decimal
but after compiling this im getting an arrayoutofbound exception
eg: 541656(its the input) Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6 at binarywa.binaryadd.main(binaryadd.java:16)