Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
Weil das zwei unterschiedliche Instanzen sind und die hashCode() Implementierung von java.lang.Object verwendet wird.wieso erhalte ich bei folgendem code-snippet nicht den selben HashCode?
/**
*
*/
package de.tutorials;
import java.util.Arrays;
/**
* @author Thomas
*
*/
public class IntArrayHashCodeExample {
/**
* @param args
*/
public static void main(String[] args) {
int[] a1 = new int[]{1,2,3};
int[] a2 = new int[]{1,2,3};
System.out.println(Arrays.hashCode(a1));
System.out.println(Arrays.hashCode(a2));
}
}
/**
* Returns a hash code based on the contents of the specified array.
* For any two non-null <tt>int</tt> arrays <tt>a</tt> and <tt>b</tt>
* such that <tt>Arrays.equals(a, b)</tt>, it is also the case that
* <tt>Arrays.hashCode(a) == Arrays.hashCode(b)</tt>.
*
* <p>The value returned by this method is the same value that would be
* obtained by invoking the {@link List#hashCode() <tt>hashCode</tt>}
* method on a {@link List} containing a sequence of {@link Integer}
* instances representing the elements of <tt>a</tt> in the same order.
* If <tt>a</tt> is <tt>null</tt>, this method returns 0.
*
* @param a the array whose hash value to compute
* @return a content-based hash code for <tt>a</tt>
* @since 1.5
*/
public static int hashCode(int a[]) {
if (a == null)
return 0;
int result = 1;
for (int element : a)
result = 31 * result + element;
return result;
}