I am beginner in java.Now i'm facing problem during pratice.Actually i want to get String tokens from a StringTokenizer class and wanna assign these tokens to the array of string.but i'm getting null pointer exception.My code is here.
public class Token {
public static void main(String str[])
{
String str1="This is my first page";
StringTokenizer str2=new StringTokenizer(str1);
int i=0;
String d[]=null;
while(str2.hasMoreTokens())
{
d[i]=str2.nextToken();
}
System.out.println(d);
}
}
String d[]=null;Why do you do that? (Then, when you writed[i].somethingit's like writinnull.somethingwhich causes NPE).