I am suppose to use methods in order to count number of words in the a sentence. I wrote this code and I am not quite sure why it doesn\'t work. No matter what I write, I on
class Words {
public static void main(String[] args) {
String str="Hello World this is new";
str=str.trim();
int n=str.length();
char a[]=new char[n];
str.getChars(1,n,a,0);
for (int i=0;i