Joanne
brando brandido wrote:so i believe i have to use the StringTokenizer class and its methods.
The program should work for any course details following the above format (i.e., ABC 123 : Course Description)
can anyone have any idea? (i don't like scanner ok? hehe, maybe java.util, stringtokenizer only)
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:Welcome to the Ranch
If you read about StringTokenizer, you find you ought not to use it in new code. You should try reading about the String class’ methods. If you click on Pattern you will find a brief list of regular expressions. Remember if you need the \ you will probably have to write \\.
D. Ogranos wrote:Slightly off topic: I've never understood why StringTokenizer should not be used anymore...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
D. Ogranos wrote:Slightly off topic: I've never understood why StringTokenizer should not be used anymore...
Because, as Campbell mentioned quite a while ago, the documentation says so. Specifically:
"StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split() method of String or the java.util.regex package instead."
Winston
D. Ogranos wrote:
Winston Gutkowski wrote:
D. Ogranos wrote:Slightly off topic: I've never understood why StringTokenizer should not be used anymore...
Because, as Campbell mentioned quite a while ago, the documentation says so. Specifically:
"StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split() method of String or the java.util.regex package instead."
Winston
Yeah I know that, but there's no good reason given from what I've seen as to WHY its use is discouraged. Regular expression are more powerful, sure, and you can do things with them that you can't with the StringTokenizer. But there is no fundamental problem with the class, so why should one not use it if the limitations are not a problem?
D. Ogranos wrote:Yeah I know that, but there's no good reason given from what I've seen as to WHY its use is discouraged. Regular expression are more powerful, sure, and you can do things with them that you can't with the StringTokenizer. But there is no fundamental problem with the class, so why should one not use it if the limitations are not a problem?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:Like Enumeration it's not deprecated.
Rob Spoor wrote:Like Enumeration it's not deprecated.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Not at all. The requirement was for there to be no colon before 102.Korhan Rankin wrote: . . . Simply add a second ":" character as separator. . . .
Winston Gutkowski wrote:
D. Ogranos wrote:Yeah I know that, but there's no good reason given from what I've seen as to WHY its use is discouraged. Regular expression are more powerful, sure, and you can do things with them that you can't with the StringTokenizer. But there is no fundamental problem with the class, so why should one not use it if the limitations are not a problem?
Well, I'd say that its a bit like putting drum brakes on a new car when it's well known that disks are a lot better.
Dennis Deems wrote:No, it's not really like that. It's been demonstrated that the speed of StringTokenizer is superior to both regex and String.split...
...So if speed happens to figure into one's definition of "better", then clearly the legacy code is better.
Use the right tool for the job. Not the shiniest.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Dennis Deems wrote:No, it's not really like that. It's been demonstrated that the speed of StringTokenizer is superior to both regex and String.split...
It has? I only heard a claim so far, no references.
I would say that if you plan on using a class whose use has been actively discouraged by the writers of the language for at least 3 full releases now (I went back to 1.4.2), you should be prepared to defend your decision
I would say that if you plan on using a class whose use has been actively discouraged by the writers of the language for at least 3 full releases now (I went back to 1.4.2), you should be prepared to defend your decision
"How do you define fool?"
"I don't attempt it. I wait for demonstrations. They inevitably surpass my imagination."
Noam Ingalls wrote:But this is begging the question. It was asked WHY the use of StringTokenizer is discouraged, and no satisfactory response has been forthcoming.
Dennis Deems wrote:But this is begging the question. It was asked WHY the use of StringTokenizer is discouraged, and no satisfactory response has been forthcoming.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
permaculture is giving a gift to your future self. After reading this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|