Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1058
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: How would you do this kind of validatioin checking |
| Date | 2011-09-13 12:27 -0700 |
| Organization | Canadian Mind Products |
| Message-ID | <0cbv67hln8kgv6a9i9rb91o3cfr9geek3m@4ax.com> (permalink) |
| References | <mp9t6719gf0b4hhjjmk9od1j5g97e7ndoe@4ax.com> <4oot67hso1eer84d8ahpl9u1vtk160ajvr@4ax.com> <8dnu67lakhvfuo71j1sna3qmfdkn583egj@4ax.com> |
On Tue, 13 Sep 2011 08:44:00 -0500, "Thee Chicago Wolf [MVP]" <.@.> wrote, quoted or indirectly quoted someone who said : >As one of the other posters suggested, it could be set up to throw an >exception and loop until valid input is entered. Right now we're not >up to exceptions in my class but it seems to be down the road so I am >going to read ahead and see if I can get the gist of how exceptions >work. Thanks much! You could then have your nextInt check for validity and return a flag. Without exceptions, it would be somewhat awkward to validate and convert to int. You would have to recreate the logic inside Integer.parseInt. I used to teach a tutorial in computer science at UBC. If one of my students used a feature we had not covered yet, I would be very happy, so long as it was clear he/she had not just been handed the answer by an advanced student. If I were you, I would just read up on exceptions. They are not that difficult, much easier than trying to reinvent the wheel. They were invented because of the way propagating flags can get so awkward in C. -- Roedy Green Canadian Mind Products http://mindprod.com The modern conservative is engaged in one of man's oldest exercises in moral philosophy; that is, the search for a superior moral justification for selfishness. ~ John Kenneth Galbraith (born: 1908-10-15 died: 2006-04-29 at age: 97)
Back to comp.lang.java.help | Previous | Next — Previous in thread | Find similar
How would you do this kind of validatioin checking "Thee Chicago Wolf (MVP)" <.@.> - 2011-09-12 20:12 -0500
Re: How would you do this kind of validatioin checking Knute Johnson <nospam@knutejohnson.com> - 2011-09-12 18:44 -0700
Re: How would you do this kind of validatioin checking Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-09-12 21:58 -0400
Re: How would you do this kind of validatioin checking "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-13 08:41 -0500
Re: How would you do this kind of validatioin checking Roedy Green <see_website@mindprod.com.invalid> - 2011-09-12 21:59 -0700
Re: How would you do this kind of validatioin checking "Thee Chicago Wolf [MVP]" <.@.> - 2011-09-13 08:44 -0500
Re: How would you do this kind of validatioin checking Roedy Green <see_website@mindprod.com.invalid> - 2011-09-13 12:27 -0700
csiph-web