Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I wrote essay just a second ago, but lemme 1st ask one thing:

 

private final HashMap<String, String[]> args = new HashMap<String, String[]>();

 

Is this shit consistent?

 

this.args.hashCode()

 

Everything from docs tell me it is:

* Map.hashCode() is sum of all hashcodes of entries in map

* String has consistent hashCode since JVM 1.2 (I think)

* Only thing left is String[] - which I THINK is also consistent?

 

Anyway - 6 SAME (edit: their elements and order of adding) maps like this, with same input, 3 on server and 3 on client logical side - each of those return different hash!

Also - if I'd loop them and put their elements into NBT the NBT will be equal, damn - even ordering is the same.

 

Java masters - teach me. (Today I've travelled (~4hours) through 7 inheritance hashCode() methods and finally arrived where they start being different - and that is on this situation above).

1.7.10 is no longer supported by forge, you are on your own.

Did you check if they are equal by equals method?

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Hi

 

Without thinking about it too hard, I would say that the hashcode of a String [] might just be the object reference, i.e. a shallow hashCode.  This will be different for each instance of the String [] regardless if all the Strings in the array are identical.

 

If this is important to you, perhaps you could replace String [] with a container class that does deep hashCode on the Strings it is holding.

 

-TGG

 

  • Author

At point of writing this I was going to sleep (no time to check), but yeah - Object[] was the shit.

 

Until now, I always preferred (in my mod's parts of code) String[] to any List<String> - reason is obviously less memo and fact that those were used with commands and configs:

execute(ICommandSender ics, String[] args)

ConfigCategory#getStringList()

 

Anyway, spent about 2h to convert like hundreds of fields and methods to ArrayList<String>.

 

Thank for reassuring. (that was my hashing problem).

1.7.10 is no longer supported by forge, you are on your own.

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.