This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Whats wrong with this code :( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Whats wrong with this code :(" Watch "Whats wrong with this code :(" New topic

Whats wrong with this code :(

Peter Shipway
Ranch Hand

Joined: Mar 25, 2004
Posts: 71
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ April 05, 2004: Message edited by: Dirk Schreckmann ]
Carlos Failde
Ranch Hand

Joined: Oct 20, 2000
Posts: 84
The inequailty operator in java is != not <>
memory = memory - 1024;
d = d + 1;
for example could be written as:
memory -= 1024;
but that's a matter of personal taste I guess.
The TerminalIO package is from a book perhaps so I can't comment on that.
Use ubb code tags around your code in future as it makes it easier for ranchers to read.
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

When posting code sample(s), it is best if you place them inside UBB [code] tags. This will retain your code�s indentation and formatting when it is displayed (at least in most web browsers). It will also cause most web browsers to use a monospaced font when displaying it. All of this makes reading the code much easier. Some folks won't even try to read your code if it is not in [code] [/code] tags.
Take a look at the information on the Using UBB Tags page for more information. But ultimately, it is as simple as placing your code between a set of [code] and [/code] tags.
So if in the posting window you type:
public class SomeClass
    more code typed here
It will be displayed as:

Regards, and welcome to the ranch.
Peter Shipway
Ranch Hand

Joined: Mar 25, 2004
Posts: 71
Thanks for the tip and the info about UBB codes, I changed the <> operater to != and It still dosent work, Its like its an never-ending loop, my machine usally crashes... Oh and I have terminalIO package set-up correclty on my computer, tested other programs...
[ April 05, 2004: Message edited by: Peter Shipway ]
Tobias Hess
Ranch Hand

Joined: Apr 06, 2004
Posts: 55
Just make a simple test with pencil and paper:
let memory become 64
memory > 1024 --> no
memory > 64 --> no
Therefore, memory stays 64, and it loops forever. Try
memory >= 64
and see, what happens. ;-)
BTW, what if I enter something like 64 + 1? Or is this considered as invalid input?
I agree. Here's the link:
subject: Whats wrong with this code :(
It's not a secret anymore!