colton peterson

Ranch Hand
+ Follow
since Nov 18, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by colton peterson

I myself wasn't even aware there was a public or private JRE, but a quick google search turns up this. He does a pretty good job of explaining the differences, basically the public JRE is the one you want everything else on the computer to use, and a private JRE is just if you need to have multiple versions of the JRE on the computer.
11 years ago
I am still thoroughly confused, for the following reasons:

The printlns in your code do not match the output you gave

Even though you mentioned that the algorithms are supposed to sort something, it looks to me like they are for searching through arrays using different methods, not sorting them

Also you have no main method, and your methods do not call each other, so I do not even know which method you are asking about, as they do different things

40 the position of the match is 16


this line in particular, what does it mean? When searching for 40 it returns that the position is 16? Vice versa? something else entirely?

In the method interpolationSrch() (which I think is the one you are asking about), what do v, s, and e mean? value, start, end? those one letter parameters are killing me. If so I still need to know what you originally call it with to be much more helpful.

I am not trying to sound harsh, I am just very confused, if you could clarify any of the above points, I am sure we could be a lot more helpful in answering your questions
11 years ago


so 'this' can be thought of as a variable that points to the current instance of the class, the most advanced usage I can think of would be using the 'this' keyword to call another constructor from a constructor within the same class, which is covered (as is all of this) in the tutorial referenced earlier
11 years ago
try making your concurrentLinkedQueue volatile, if that doesn't work then move your synchronized statement to inside the endless loop, or better yet, just around the code that needs to be protected
15 years ago
What exactly does "synchronized (lock)" mean (sorry threads are not my speciality) I assume that it means that only one thread can access the code inside of it at a time. If so then you have an endless loop inside of that block of code, and so the lock to that code will never be released once it has started. Also is that your entire output? if not then please post all of it.

Also why do you need two BufferedReaders, that probably doesn't effect your code at all, but I don't see why you would need to.

One more thing. You call System.exit() as soon as you finish starting all the threads. Won't that just end all the threads? You should probably wait until you are done serving all the students
15 years ago
You will probably use the System.in input stream so you will want to look at the following classes:
java.lang.System
java.io.InputStream
java.nio.InputStreamReader
java.io.BufferedReader

what I would do is wrap the System.in into a InputStreamReader, which I would then wrap in a BufferedReader eg

BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

then you can use BufferedReader's readLine() method to see when the user presses enter. Probably not as simple as you are looking for, but I think that is about as simple as it gets with the standard API
15 years ago
oh I use an IDE, it's called geany, it is a general purpose IDE for a lot of different languages. It doesn't have things like auto import managing, but it is much better than textpad + command prompt
15 years ago
hmm, interesting article. It makes sense, but he wasn't as clear as he could have been on how to avoid getters ands setters and still make the code work. If you wanted to avoid getters and setters, you could pass the value of rabbitNumber in a constructor, though I'm not sure if that is any more or less OO then getters and setters
15 years ago
oh, that also makes sense, I'm trying not to use one of the IDE's until I know more about how java works on the inside.
15 years ago
Interesting, I've always been taught that encapsulation was very OO. I don't know for sure, and could easily be wrong however. But beyond that I am lost, as I don't know any other way to achieve what you want to do, except through encapsulation. If there is another way, I would love to learn it.
15 years ago
where and how is your num variable initialized? you could also try replacing "num", with this (that is the java keyword 'this"), provided you have a toString() method for Clerk. However that may or may not work, depending on if your toString() method just prints out the num again. I would try it anyway
15 years ago
ah, the API has three timer classes, I could see where that could create conflict, thanks.
15 years ago
what does your run method have so far? Are you just in a loop, waiting to help the students? If you have any code please post it.
15 years ago
whenever I import code, I always use the wildcard eg:

import java.util.*;

but in a lot of people's code, they import a class at a time eg:

import java.util.ArrayList;

what are the advantages and disadvantages to each? I know that importing a whole package doesn't slow the code down at all, so I see no reason to import specific packages.
15 years ago
I would say that getters and setters are your best bet. If you only are going to have one instance of that number per game, then you could make it static, if that helps at all.
15 years ago