Problem :
I have very recently started to learn programming in Java. I am trying to execute my java code but I am facing the below error.
“Exception in thread "main" java.lang.arrayindexoutofboundsexception:”
I am unable to understand above error.
Please find below my code:
public static int[] myoddSort ( int myinput[] )
{
int myamountOfOdd = 0;
int j = 0;
for(int i = 0; i < myinput.length; i++)
{
if (myinput[i] % 2 != 0)
myamountOfOdd++;
}
int[] myodd = new int[myamountOfOdd];
for(int i = 0; i <= 199; i++)
{
if (myinput[i] % 2 != 0)
/* This line is not working, according to my debugger*/
myodd[j] = input[i];
j++;
}
return myodd;
}
Please help me in fixing above error.