Tom Reilly

Rancher
+ Follow
since Jun 01, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
32
Received in last 30 days
0
Total given
4
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tom Reilly

I Googled the error and a couple of items suggested that the port is already in use. I noticed that your server loops forever and does not clean up after itself (by calling DatagramSocket.close). Could it be that another instance is already running? Or maybe not cleaning up caused the port to remain open? Or perhaps another application is using that port? Try using another port or rebooting to close the existing port (both easy tests).

I tried running your server and got a different error (Address already in use) when I tried running it a second time but I'm not running on Windows.
This code will not stand the test of time :-) For the following code,

What happens, for example, if one.year is Integer.MIN_VALUE and two.year is 1? Your code will claim them to be equal (subtracting one from Integer.MIN_VALUE results in zero). I point this out not for this example but if you have a situation where you are comparing ints that could be negative, you could have a bug.
12 years ago
Also check your container log files for any indication of an error.
I usually find Carmen Sandiego by taking 94 West. Make a right on F Street and a left on Broadway.
I googled your error and many of the items returned referred to NetBeans. Is that what you are using? One of them said try a build clean.

BTW, you have a bug at line 184. Do you see it?
12 years ago

EDIT: sorry, i also have to print a bar graph for grade, so if there are 4 A grades, it should output A: 4 ####

the only way i could think to do this was use this, but it doesn't work:

view plaincopy to clipboardprint?

1. String pound = " #";
2.
3. String star = (String.valueOf(numA));
4. star = star.replace(star, pound);
5.
6. System.out.println("A: " + numA + star);

String pound = " #"; String star = (String.valueOf(numA)); star = star.replace(star, pound); System.out.println("A: " + numA + star);

it replaces star with a single pound sign even though star should be the value of A. maybe.


Instead of using

Look at using System.out.print(). On one line, print out the "A: ". Then in a loop, print out a "* ". The number of iterations through the loop will be the number of A grades. Then after the loop do a System.out.println().
12 years ago

it works! the second part of my problem was the sentinel value. it counts -999 as a grade, so it tells me there are 10 F grades even though there are only 9. i have it written this way because the TA of my class walked us through that part. does the mean she missed something, or did i? it's happening because Java works through the first bad value and then stops, right? but i don't want it to count the sentinel, just acknowledge that it exists and terminate.


I ran your code using the input you specified. The output was 9 F grades - not 10.
12 years ago
Yes, it has something to do with super classes or something. If you want Root to be a super class (parent) of Animal then you define Animal as:

If you want Animal to be a parent of Root then you define Root as:
12 years ago
Well the error message says it all. You must return a String value in your method. For example, I added return encryptedString; at the end of your method as shown below. You will, of course, have to modify the code so that it is correct. The code the way you have written it will always return an empty String.
12 years ago

When i compile and run your code I get a 180k file that is all printable text.


It worked for me too. ~215K file.
12 years ago
weightList[0]= s; is a statement. All java statements must be in a method or constructor or code block. You cannot just add a statement to a class. Adding braces around the weightList[0]= s; statement (putting it in an initializer code block) fixes the problem. You could also initialize weightList[0] in a constructor.
Your error doesn't have anything to do with enums. is a statement. All java statements must be in a method or constructor or code block. You cannot just add a statement to a class. Placing the statement in the main() method fixed the error. But adding braces around the enumObj = EnumA.B; statement (putting it in a code block) would also have solved it. You could also initialize the enumObj variable like this:
BTW, It helps readability when you use code tags to display your code. Here's your code when you use code tags (and indentation):
As Sheriff Wong said, if your JavaMusicPlayerBasic class implements Runnable then it has to have a method called run(), which it does not.

But I don't think you should have your JavaMusicPlayerBasic class implementing Runnable. Correct me if I'm wrong but I don't think you want the whole dialog box running in a separate thread, you just want to play the mp3 in a separate thread so that your dialog box still responds to user input.

I would create a separate class that implements Runnable. Call it, for example, Mp3Player. Then in your jButton_browseActionPerformed() method, instead of creating an instance of Player, you would create an instance of Mp3Player and call its start() method. Calling start() creates a new thread and calls the run() method on that new thread. Move the creation of Player and the play() method from jButton_browseActionPerformed() to the run() method of Mp3Player so that the mp3 file is played on the new thread.
12 years ago
I don't know if this is the problem about which you are asking but don't you need a space between your single quote and "and"? That is,
It would help if you describe the trouble you are having.
13 years ago