Campbell Ritchie

+ Follow
since Oct 13, 2005
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Campbell Ritchie

There are so many changes between Java7 and Java8 that I would suggest you are better off getting the Java8 book.
Please put the [/code] part of the code tags after the code; then the code will look like this:-Please remind yourself about the correct syntax for try with resources[←link], which is what you are writing. I can't remember whether you need to follow it with a catch, but you certainly need a pair of {}. What does line 6 mean? I think that should be in the () after try, too. Line 6 is also incomplete, so that will throw the compiler off for everything which follows it. There is a common beginner's error at the end of line 8. Line 11 is unnecessary, as you will find out from that Java™ Tutorials link I gave you earlier. Also it may cause you problems later on. What are you using the Print Writer for?

I am pleased to see you have been taught try with resources, and Files#newBufferedReader for opening a buffered reader.
Minor point: your spacing before and after operators is inconsistent.

Agree with Fred about writing lots of codes and then trying to fix it. If you get multiple compiler errors, correct the very first error and recompile. Chances are several other errors caused by that first error will vanish mysteriously.

And . . . welcome to the Ranch
1 day ago
Done. Thank you for being understanding about editing.

Line 2 should have been written as two lines. Yes, I think that will work. Since you are using [pseudo]random numbers, you cannot predict how long it will take to get 666, but it should average out at 1 in 216. I presume you will therefore run the loop repeatedly and calculate an average.
3 days ago
Because in the past we had frequent problems with people “correcting” mistakes in old posts, so the replies looked like nonsense. Shall I correct the code tags for you?
Don't use <> for code tags: it's [], but the button is quicker. The HTML <code> tag changes the font and I have only seen it used in javadoc comments.
3 days ago
That's a pleasure
3 days ago

Henry Wong wrote:. . . . check if the value is infinity or negative infinity . . . .

That will identify overflow, but you can't reliably detect underflow because 0.0 might be a permissible result anyway.

It is worth looking through the Math class and the Double class to see whether there are any exactXXX methods or multiplyExact or similar which are designed to seek overflow and underflow. I did. I couldn't find any. Does it say anything in the Java® Language Specification or JVM specification about overflow and underflow? I don't remember seeing anything. So I think there is no such thing as an overflow‑resistant JVM.
3 days ago
Also, why are you using multiple arrays in parallel? That is often a sure‑fire recipe for trouble later on
3 days ago
Somebody has pointed out my mistake, missing that you found Arrays.toString(). Sorry about that
1 week ago

André Monteiro wrote:. . . I'm thinking I did again.   

No, you haven't done anything now. Look here for an easier way to print an array.
1 week ago
Don't put so much code in the main() method. Don't put so much code in each case: use separate methods.Don't use System#exit. If you have a loop with while(option != 4) in, that loop will terminate whenever 4 is entered, and you simply allow control to pass to the end of the method.
Don't create multiple Scanner objects reading from You only need one Scanner instance.
1 week ago
Welcome to the Ranch

We usually don't allow full solutions, but it is over two days since the preceding post, so I shall let that pass. There is a much better way to print an array than what all posts here show. What do you mean about adding the package?
1 week ago
Welcome to the Ranch Short answer: don't know. Longer answer: what happens when you call that pauseXXX method? Are you blocking all your threads? Maybe you need a different thread for each entity? Not sure. Are you using the Event Dispatch Thread? Are you calling Thread#sleep() anywhere, or something similar?
1 week ago
Please show us what you mean with an example.
1 week ago

Mike London wrote:. . . No need to be snotty. . . .

Agree. We shall keep an eye on that user. Well done standing up for yourself
1 week ago
Previously in this thread.

Please don't hi‑jack threads by asking questions unrelated to the original subject. Fortunately I can split you off into a new topic. I don't have the time to go through Mix4 at the moment, but I would warn you it is more complicated than it looks at first sight.
1 week ago