NullPointerException
I can't see why this code doesnt work. maybe someone else can help me see the problem? I get a NullPointerException when it reaches either of the inner IF statements that decide where the letter should be assigned.
if this isnt clear enough please aks and I will try to clarify!
THANKS! =)
public VowelCons(String str)//CTor that takes in a string from user
{
String lwrstr = str.toLowerCase();// assign the String lwrstr all lowercase letters from String str
char [] strArray = lwrstr.toCharArray();// convert the String lwrstr into a character array strArray
for (int i = 0; i < strArray.length; i++)
{
// if index[i] of the array strArray is equal to any of these vowels then....
if(strArray[i] =='a' || strArray[i] =='e' ||
strArray[i] =='i' || strArray[i] =='o' || strArray[i] =='u')
{
// another counter to try and keep the array index together and no null indexes in between
for(int j = 0; j <= strArray[j]; j++)
{
vowels[j] = strArray[i];// assign strArray[i] to the character array vowels[j] NullPointerException ERROR
}
}
else// or else they are consonants
{
// another counter to try and keep the array index together and no null indexes in between
for(int k = 0; k <= strArray[k]; k++)
{
consonants[k] = strArray[i];// assign strArray[i] to the character array consonants[k] NullPointerException ERROR
}
}
}
}

