Question

hi, here am writing the method that count the words in a String but can anyone tell me plz how can i apply this to TextField? maybe i have to change whats written in the TextField to String? and how?

public static int Count(String s)

{

int wordCount=0, charCount=0;

String word;

StringTokenizer tokenizer;

tokenizer = new StringTokenizer(s);

while(tokenizer.hasMoreTokens()){

word=tokenizer.nextToken();

wordCount++;

charCount+=word.length();

}

return wordCount;

}

Thanks

Abed

[576 byte] By [Abed_Ghamlousha] at [2007-10-2 9:13:00]
# 1
I would assume that TextField has a getText or getContents or somesuch method that returns the contents as a String.
jverda at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 2
Hi,You can get the text from the textfield as a String by calling getText on the field.Kaj
kajbja at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 3
Please use [code] and [/code] tags when you post your code, as it is explained in [url http://forum.java.sun.com/help.jspa?sec=formatting]Formatting Tips★[/url]. It help us to read and understand your code more easily.
Marcelo9a at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 4
yeah guys, getText , its working , thx alotAbed
Abed_Ghamlousha at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 5
Tip: Try to use more specific subject lines. The more meaningful your subject, the more meaningful your replies.
Dick_Adamsa at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 6

> Tip: Try to use more specific subject lines.

> The more meaningful your subject, the more meaningful

> your replies.

Could you please stop posting these advices? There is no meaning to post this in threads which are "closed".

Can't you just post the message into threads which are still alive, and which you are posting answers to?

Kaj

kajbja at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 7
> Can't you just post the message into threads which> are still alive, and which you are posting answers> to?Don't you see he's posting his "advise" all over the place?
CeciNEstPasUnProgrammeura at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 8

> > Can't you just post the message into threads which

> > are still alive, and which you are posting answers

> > to?

>

> Don't you see he's posting his "advise" all over the

> place?

Yes I've seen that, and that's why I told him to stop. I hate when he does that.

Kaj

kajbja at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...
# 9
Go ****_Adams Go! You're our hero!*cough* Not *cough*
warnerjaa at 2007-7-16 23:20:03 > top of Java-index,Java Essentials,Java Programming...