<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://en.zaoniao.it/index.php?action=history&amp;feed=atom&amp;title=Java_hashCode%28%29</id>
	<title>Java hashCode() - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://en.zaoniao.it/index.php?action=history&amp;feed=atom&amp;title=Java_hashCode%28%29"/>
	<link rel="alternate" type="text/html" href="http://en.zaoniao.it/index.php?title=Java_hashCode()&amp;action=history"/>
	<updated>2026-05-15T10:18:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.32.0</generator>
	<entry>
		<id>http://en.zaoniao.it/index.php?title=Java_hashCode()&amp;diff=5509&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;In the Java programming language, every class implicitly or explicitly provides a &lt;code&gt;hashCode()&lt;/code&gt; method, which digests the data stored in an instance of the class int...&quot;</title>
		<link rel="alternate" type="text/html" href="http://en.zaoniao.it/index.php?title=Java_hashCode()&amp;diff=5509&amp;oldid=prev"/>
		<updated>2019-06-05T04:18:16Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;In the Java programming language, every class implicitly or explicitly provides a &amp;lt;code&amp;gt;hashCode()&amp;lt;/code&amp;gt; method, which digests the data stored in an instance of the class int...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In the Java programming language, every class implicitly or explicitly provides a &amp;lt;code&amp;gt;hashCode()&amp;lt;/code&amp;gt; method, which digests the data stored in an instance of the class into a single hash value (a 32-[[bit]] signed integer). This hash is used by other code when storing or manipulating the instance – the values are intended to be evenly distributed for varied inputs for use in clustering. This property is important to the performance of hash tables and other data structures that store objects in groups (&amp;quot;buckets&amp;quot;) based on their computed hash values. Technically, in Java, &amp;lt;tt&amp;gt;hashCode()&amp;lt;/tt&amp;gt; by default is a native method, meaning, it has the modifier 'native', as it is implemented directly in the native code in the JVM.&lt;br /&gt;
&lt;br /&gt;
==&amp;lt;tt&amp;gt;hashCode()&amp;lt;/tt&amp;gt; in general==&lt;br /&gt;
All the classes inherit a basic hash scheme from the fundamental base class &amp;lt;tt&amp;gt;java.lang.Object&amp;lt;/tt&amp;gt;, but instead many override this to provide a hash function that better handles their specific data. Classes which provide their own implementation must override the object method &amp;lt;tt&amp;gt;public int hashCode()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The general contract for overridden implementations of this method is that they behave in a way consistent with the same object's &amp;lt;tt&amp;gt;equals()&amp;lt;/tt&amp;gt; method: that a given object must consistently report the same hash value (unless it is changed so that the new version is no longer considered &amp;quot;equal&amp;quot; to the old), and that two objects which &amp;lt;tt&amp;gt;equals()&amp;lt;/tt&amp;gt; says are equal ''must'' report the same hash value. There's no requirement that hash values be consistent between different Java implementations, or even between different execution runs of the same program, and while two ''unequal'' objects having different hashes is very desirable, this is not mandatory (that is, the hash function implemented doesn't need to be a [[perfect hash function|perfect hash]]).&lt;br /&gt;
&lt;br /&gt;
For example, the class &amp;lt;tt&amp;gt;Employee&amp;lt;/tt&amp;gt; might implement its hash function by composing the hashes of its members:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
public class Employee {&lt;br /&gt;
 int employeeId;&lt;br /&gt;
 String name;&lt;br /&gt;
 Department dept;&lt;br /&gt;
&lt;br /&gt;
 // other methods would be in here&lt;br /&gt;
&lt;br /&gt;
 @Override&lt;br /&gt;
 public int hashCode() {&lt;br /&gt;
 int hash = 1;&lt;br /&gt;
 hash = hash * 17 + employeeId;&lt;br /&gt;
 hash = hash * 31 + name.hashCode();&lt;br /&gt;
 hash = hash * 13 + (dept == null ? 0 : dept.hashCode());&lt;br /&gt;
 return hash;&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==The &amp;lt;tt&amp;gt;java.lang.String&amp;lt;/tt&amp;gt; hash function==&lt;br /&gt;
In an attempt to provide a fast implementation, early versions of the Java &amp;lt;tt&amp;gt;String&amp;lt;/tt&amp;gt; class provided a &amp;lt;tt&amp;gt;hashCode()&amp;lt;/tt&amp;gt; implementation that considered at most 16 characters picked from the string. For some common data this worked very poorly, delivering unacceptably clustered results and consequently slow hashtable performance.&lt;br /&gt;
&lt;br /&gt;
From Java 1.2, &amp;lt;tt&amp;gt;java.lang.String&amp;lt;/tt&amp;gt; class implements its &amp;lt;tt&amp;gt;hashCode()&amp;lt;/tt&amp;gt; using a product sum algorithm over the entire text of the string.&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
&lt;br /&gt;
[http://wikipedia.org/ http://wikipedia.org/]&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming language]]&lt;br /&gt;
[[Category:Checksum algorithms]]&lt;br /&gt;
==See Also on BitcoinWiki==&lt;br /&gt;
* [[Bitcoin Sun]]&lt;br /&gt;
* [[Best Bitcoin Blackjack]]&lt;br /&gt;
* [[Bitcoin.it Wiki Contributors' Award]]&lt;br /&gt;
* [[Bitcoin Report]]&lt;br /&gt;
* [[Ahoolee]]&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
		
	</entry>
</feed>