aspose file tools*
The moose likes Beginning Java and the fly likes 2 Basic java questions. While loops and... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "2 Basic java questions. While loops and..." Watch "2 Basic java questions. While loops and..." New topic
Author

2 Basic java questions. While loops and...

Ben Cramphorn
Greenhorn

Joined: May 13, 2004
Posts: 17
Firstly, what is wrong with the followingpiece of code??



When I run my program it keeps on getting stuck in a loop.

Secondly is there a command which allows me to clear all the text on a screen and move my and move my cursor back to the top of the screen???

Thanks alot....
Ben Cramphorn
Greenhorn

Joined: May 13, 2004
Posts: 17
Meh I figured it out.. I needed to put & instead or OR... my bad...
Ben Baker
Greenhorn

Joined: May 13, 2004
Posts: 5
Why don't your uni's name down as well ..... FY(N)
Ben Cramphorn
Greenhorn

Joined: May 13, 2004
Posts: 17
Who Be You?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Ben,

You should also consider using && and || instead of & and |. The difference is that && and || can "short circuit" the evaluation as soon as it discovers what the result must be. As an example, if you have an expression (x && y) and x evaluates as false, then y is never even evaluated. Similarly for the expression (x || y) evaluates x as true, then y is not evaluated.

Keep coding!

Layne


Java API Documentation
The Java Tutorial
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Some of us old timers have the advantage (?) of coming from a COBOL background. The language lets you leave out certain repetitious parts of the syntax for brevity:

Of course humans say "if a not 1 or 2 or 3" so we coded it wrong about half the time - exactly as you did. After a few thousand errors - stare at the code for a day and not see why it doesn't work - we all learn to stop and look at these things twice before going on. So welcome aboard! If you learned to stop and examine any "and" and "or" code on the first error you're way ahead!


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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 Basic java questions. While loops and...