Hey guys wassup! i need your help... Given a string, how do you count number of white spaces in it, together with number of digits?... waiting to hear from you soon..
Richard Green
Ranch Hand
Joined: Aug 25, 2005
Posts: 536
posted
0
split the string into char array...loop through....count.....
MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
If those answers sound too advanced, let's look at doing the work in smaller steps.
The String class has a method that will give you an array of char. The Character class has methods to tell if a char is a digit or whitespace.
Can you imagine a loop through the array, checking each character, adding to counters for digits and whitespace? Give it a shot and show us what you make. We can help you best with "almost working" code.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Alan Moore
Ranch Hand
Joined: May 06, 2004
Posts: 262
posted
0
Regexes are definitely not the tool for this job. It will be far easier to iterate through the characters yourself, as Stan suggested (and that's almost certainly what your instructor is expecting you to do). [ January 31, 2007: Message edited by: Alan Moore ]
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.