NullPointerException

i keep getting the nullpointerexception.. i know that it means that my array is empty.. i just dont understand why its empty..

help pls.. ..thanks in advance

import java.util.*;

publicclass capitalize{

publicstaticvoid main(String args[]){

Scanner kybd =new Scanner(System.in);

String phrase;

String caps =null;

System.out.println("Input Sentence to capitalize");

System.out.println();

phrase = kybd.nextLine();

caps= printCapitalize(phrase);

}

static String printCapitalize(String a){

String newA;

char array[] =null;

for(int x = 0; x<a.length();x++){

array[x] = a.charAt(x);// i know it happens here

}

System.out.println(array);

for(int x = 0; x><array.length;x++){

if(Character.isLetter(array[x])){

Character.toUpperCase(array[x]);

//return array[x];

}

}

newA = String.copyValueOf(array);

return newA;

}

}

>

[1976 byte] By [Arch_Bytesa] at [2007-11-26 19:07:24]
# 1
> i know that it means that my array is empty.. i just dont understand why its empty..array is not empty, it's null.You need to create a new array of the appropriate length.
pbrockway2a at 2007-7-9 20:59:45 > top of Java-index,Java Essentials,New To Java...
# 2
oh i see.. yey! thanks..^_^
Arch_Bytesa at 2007-7-9 20:59:45 > top of Java-index,Java Essentials,New To Java...
# 3
You might find this useful, also. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#toUpperCase()You'll need to add the () onto the url, seeing as how it doesn't think it's part of it normally.
JJCoolBa at 2007-7-9 20:59:45 > top of Java-index,Java Essentials,New To Java...
# 4
thanks for ur help JJ ^_^ and PB..^_^
Arch_Bytesa at 2007-7-9 20:59:45 > top of Java-index,Java Essentials,New To Java...