Queries and Questions

In the following code binchar is a char array having 98 elements and nv22 is an integer variable which has a different random value every time the program runs. The problem is it always gives me java.lang.ArrayIndexOutOfBoundsException :98 at the line ar[nv22-17]=binchar[l]; the while loop states l

System.out.println("Enter a message");
Scanner ss=newScanner(System.in);
String s=ss.nextLine();
char[] ar=s.toCharArray();

len=ar.length;
int l=0;
while(l<len)
{
for(int y=0; y<25; y++)
{
for(int x=0;x<20; x++){
 ar[nv22-17]=binchar[l];
            l++;
}
}
Advertisements

Constructive and genuine appreciation and/or criticism most welcome

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s