Carey Brown

Bartender
+ Follow
since Nov 19, 2001
Carey likes ...
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
Forum Moderator
Carey Brown currently moderates these forums:
Cows and Likes
Cows
Total received
57
In last 30 days
1
Total given
2
Likes
Total received
1081
Received in last 30 days
17
Total given
131
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carey Brown

dario lobos wrote:Also i tried with random seed and second to do a hashcode with fast expire date and with no calculation at all.


In general, the equals() method and the hashCode() methods are designed at the same time. The rule is that any two objects that are equal MUST generate the SAME hash code. If you are adding in time or random numbers into the hash code then you are breaking this design rule. Note that two objects with same hash value are not necessarily equal.

Equals() and hashCode() can take all the object's fields into account or just use the fields that make up a unique key for the object, something like: make, model, and color (assuming the three together are unique).
6 hours ago
You are doing a lot of work with date and time. It looks like you're trying to convert 'now' into milliseconds. Is this a local date/time or UTC date/time?

You seem to be using the current milliseconds in your hashCode() method. This means that every time you call hashCode() that you'll get a different value. HashCode() is supposed to return the same value for an object regardless of time.
7 hours ago
I'm having a bit of a hard time inferring your intent. I'm guessing that you want to go from a 2D array to a 2D list, but it's not clear why. Additionally, you've declared 'value' as an int and I'm assuming 'x' is a double, so how are you getting doubles  that have a fractional component?

As a wild guess at your intent. Note that this does not swap rows and columns the way it seems that yours does.
Output:


10 hours ago
You are placing a semicolon (;) after most of your closing braces ( }; ). This is almost never correct. You are getting away with it because a single semicolon by itself is an empty statement, but if you continue to do this you add confusion for your readers and could introduce bugs.

One case where it is necessary is
10 hours ago
Sorry about being kicked out, we have been experiencing some server problems on our site for the last few days.
21 hours ago
Here, I ran this through Eclipse's formatter.



1 day ago
Your Objectos class needs to override the toString() method.
1 day ago
I'm afraid that I have to ask you to repost your code. There are two problems with it:
* You have WAY too many blank lines. You should not use two blank lines in a row. You should not double space your lines unless you are specifically trying to highlight their differences.
* You have not used Code Tags which allow this site to add line numbers and preserve indenting and formatting of the code.

There is a button just above the edit window marked Code. To use it you need to do one of the following:

Drag your cursor over the entire source code (this highlights it in blue) then click Code.

Or, go to the beginning of the code and left-click once in front of the 1st character, then scroll down to the end of the code and shift-left-click after the last character. The code should now be blue and you can click the code button.

You can also click the Code button before pasting it in the edit window then move the cursor between the brackets "...][..." and paste.

Always click the button below the edit window marked "Preview" to see if it worked.
3 days ago
You would not see any difference doing a search. Where you would see a difference is if you were iterating through the Map. In the case of a HashMap the Entries would be in the order of their hash values which, from a user's perspective, would seem to be random. A TreeMap keeps the Entries in sorted order so that iterating through them would appear to make some sense to the user. If you were to implement a command to print the entire Map then a TreeMap would be useful. On the other hand, if you're just going  to search then HashMap would be faster.
3 days ago

khalil beldi wrote:i have a function which supposed to return an int .but the compiler hint me to return char c
how can this be possible ? ...


You don't have an infinite loop. The loop does have an exit condition. The method requires that you return an int. If the loop exits then the only numeric variable that you've declared is 'c'.

Highly recommend trying the infinite loop approach.
3 days ago
I merged your stuff with the following thread. I hope that is okay by you.
3 days ago
An infinite loop as shown tells the compiler that anything after the closing braces of the loop is unreachable, so a return there would never be executed.

If you try this loop and you still get compile errors then repost your current code and the COMPLETE compile error message.
3 days ago
You only want to create a single instance of Random, and certainly not every time you roll().
3 days ago
And welcome to the ranch  
3 days ago