Write hashfunction in Java
I am trying to create the data structure of a HashMap()
in Java. The HashMap has to work for a maximum of N = 1000
operations and the keys are only positive integers. What I did is the following:
class MyHashMap {
final ListNode nodes = new ListNode[1000];
// "put", "get" and "remove" methods which take
// collisions into account using "chaining".
}
to decide the placement of my new key - value pair in nodes
I always need to compute an index. I use the function:
public int getIndex(int key) { return Integer.hashCode(key) % nodes.length;}
which returns an integer between 0
and nodes.length
. But how can I write a Hashfunction in Java on my own that maps integers to some index without using Integer.hashMap(key)
?
Also the procedure is fine, I don't really need a code.
java hashmap hash-function
add a comment |
I am trying to create the data structure of a HashMap()
in Java. The HashMap has to work for a maximum of N = 1000
operations and the keys are only positive integers. What I did is the following:
class MyHashMap {
final ListNode nodes = new ListNode[1000];
// "put", "get" and "remove" methods which take
// collisions into account using "chaining".
}
to decide the placement of my new key - value pair in nodes
I always need to compute an index. I use the function:
public int getIndex(int key) { return Integer.hashCode(key) % nodes.length;}
which returns an integer between 0
and nodes.length
. But how can I write a Hashfunction in Java on my own that maps integers to some index without using Integer.hashMap(key)
?
Also the procedure is fine, I don't really need a code.
java hashmap hash-function
add a comment |
I am trying to create the data structure of a HashMap()
in Java. The HashMap has to work for a maximum of N = 1000
operations and the keys are only positive integers. What I did is the following:
class MyHashMap {
final ListNode nodes = new ListNode[1000];
// "put", "get" and "remove" methods which take
// collisions into account using "chaining".
}
to decide the placement of my new key - value pair in nodes
I always need to compute an index. I use the function:
public int getIndex(int key) { return Integer.hashCode(key) % nodes.length;}
which returns an integer between 0
and nodes.length
. But how can I write a Hashfunction in Java on my own that maps integers to some index without using Integer.hashMap(key)
?
Also the procedure is fine, I don't really need a code.
java hashmap hash-function
I am trying to create the data structure of a HashMap()
in Java. The HashMap has to work for a maximum of N = 1000
operations and the keys are only positive integers. What I did is the following:
class MyHashMap {
final ListNode nodes = new ListNode[1000];
// "put", "get" and "remove" methods which take
// collisions into account using "chaining".
}
to decide the placement of my new key - value pair in nodes
I always need to compute an index. I use the function:
public int getIndex(int key) { return Integer.hashCode(key) % nodes.length;}
which returns an integer between 0
and nodes.length
. But how can I write a Hashfunction in Java on my own that maps integers to some index without using Integer.hashMap(key)
?
Also the procedure is fine, I don't really need a code.
java hashmap hash-function
java hashmap hash-function
edited Nov 12 at 14:48
asked Nov 12 at 14:26
Giacomo
886
886
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
A simple strategy for hashing an int
value is to multiply by a large constant. If you don't use a constant, you can get very poor collision rates depending on your key distribution. It's is still possible to get poor key distribution, however it is less likely for real data.
NOTE: Unless you know the key cannot be negative, you should use Math.abs
to ensure it is non-negative.
static final int K = 0x7A646E4D; // some large prime.
public int getIndex(int key) {
return Math.abs(key * K % nodes.length);
}
A faster solution is to drop the use of %
use a multiplication and shift. e.g.
public int getIndex(int key) {
return (int) ((key * K & 0xFFFF_FFFFL) * nodes.length >>> 32);
}
What this does is turn key * K
into a fraction and is faster than using %
1
Seems like you first take the lowest 32 bits after multiplication, and in the end you use only the upper 32 bits?
– Marko Topolnik
Nov 12 at 14:57
do you maybe know where these things are explained ? e.g. how to hash an integer, a string ecc.
– Giacomo
Nov 12 at 15:02
@MarkoTopolnik In the second example, I start with the lower bits of a 64-bit value which after shifting by 32-bits at the end, act like a fraction.
– Peter Lawrey
Nov 12 at 17:09
@Giacomo all data are numbers. You either have a single value likeint
or an array or values likechar
which will require a loop but the principles are the same.
– Peter Lawrey
Nov 12 at 17:10
1
I see now. You use the 32-bit number as a scale factor which is effectively in the range (0,1).
– Marko Topolnik
Nov 12 at 18:04
add a comment |
Integer.hashCode(key)
just returns key
as result. You could write:
public int getIndex(int key) {
return key % nodes.length;
}
This way, you don't use Integer.hashCode(key)
.
Without seeing your class ListNode
, you could have a problem with your MyHashMap
structure since you are setting many elements to the same array element. For instance the key 3
and 1003
will be saved in the same node element. You must design MyHashMap
to be a list of list (or an array of list or something similar).
Maybe my question what not so clear. Doing it like I did, Integer.hashCode(key) will return an Integer value which can be everything. Taking % nodes.length this will ensure that this value has now a number which is in the range of my array nodes. If I get a value which corresponds to a cell which is already occupied, I will create (in my methods, this can not be seen in the question) a link to a new node to prevent the collision. So I don't really have the problem you are mentioning.
– Giacomo
Nov 12 at 14:43
Well you must still consider the collisions since they are possible. Of course there is hash function which reduces the collisions, but it was not in your question.
– LaurentG
Nov 12 at 14:46
@Giacomo Note:-1 % nodes.length == -1
– Peter Lawrey
Nov 12 at 14:47
@PeterLawrey i did not mention that keys are potive integers, need to edit it
– Giacomo
Nov 12 at 14:48
add a comment |
Well, first of all the hash
is something that is unique or a very rarely repeating value.
Assuming that your values will be evenly distributed you can use the remainder of division as a hash value for your key.
public int get(int key) {
return (-1 ^ key) % nodes.length;
}
Note: ifkey
is negative, this can return a negative number.
– Peter Lawrey
Nov 12 at 14:48
@PeterLawrey Yes, you're right. Fixed the answer.
– ETO
Nov 12 at 14:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264218%2fwrite-hashfunction-in-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
A simple strategy for hashing an int
value is to multiply by a large constant. If you don't use a constant, you can get very poor collision rates depending on your key distribution. It's is still possible to get poor key distribution, however it is less likely for real data.
NOTE: Unless you know the key cannot be negative, you should use Math.abs
to ensure it is non-negative.
static final int K = 0x7A646E4D; // some large prime.
public int getIndex(int key) {
return Math.abs(key * K % nodes.length);
}
A faster solution is to drop the use of %
use a multiplication and shift. e.g.
public int getIndex(int key) {
return (int) ((key * K & 0xFFFF_FFFFL) * nodes.length >>> 32);
}
What this does is turn key * K
into a fraction and is faster than using %
1
Seems like you first take the lowest 32 bits after multiplication, and in the end you use only the upper 32 bits?
– Marko Topolnik
Nov 12 at 14:57
do you maybe know where these things are explained ? e.g. how to hash an integer, a string ecc.
– Giacomo
Nov 12 at 15:02
@MarkoTopolnik In the second example, I start with the lower bits of a 64-bit value which after shifting by 32-bits at the end, act like a fraction.
– Peter Lawrey
Nov 12 at 17:09
@Giacomo all data are numbers. You either have a single value likeint
or an array or values likechar
which will require a loop but the principles are the same.
– Peter Lawrey
Nov 12 at 17:10
1
I see now. You use the 32-bit number as a scale factor which is effectively in the range (0,1).
– Marko Topolnik
Nov 12 at 18:04
add a comment |
A simple strategy for hashing an int
value is to multiply by a large constant. If you don't use a constant, you can get very poor collision rates depending on your key distribution. It's is still possible to get poor key distribution, however it is less likely for real data.
NOTE: Unless you know the key cannot be negative, you should use Math.abs
to ensure it is non-negative.
static final int K = 0x7A646E4D; // some large prime.
public int getIndex(int key) {
return Math.abs(key * K % nodes.length);
}
A faster solution is to drop the use of %
use a multiplication and shift. e.g.
public int getIndex(int key) {
return (int) ((key * K & 0xFFFF_FFFFL) * nodes.length >>> 32);
}
What this does is turn key * K
into a fraction and is faster than using %
1
Seems like you first take the lowest 32 bits after multiplication, and in the end you use only the upper 32 bits?
– Marko Topolnik
Nov 12 at 14:57
do you maybe know where these things are explained ? e.g. how to hash an integer, a string ecc.
– Giacomo
Nov 12 at 15:02
@MarkoTopolnik In the second example, I start with the lower bits of a 64-bit value which after shifting by 32-bits at the end, act like a fraction.
– Peter Lawrey
Nov 12 at 17:09
@Giacomo all data are numbers. You either have a single value likeint
or an array or values likechar
which will require a loop but the principles are the same.
– Peter Lawrey
Nov 12 at 17:10
1
I see now. You use the 32-bit number as a scale factor which is effectively in the range (0,1).
– Marko Topolnik
Nov 12 at 18:04
add a comment |
A simple strategy for hashing an int
value is to multiply by a large constant. If you don't use a constant, you can get very poor collision rates depending on your key distribution. It's is still possible to get poor key distribution, however it is less likely for real data.
NOTE: Unless you know the key cannot be negative, you should use Math.abs
to ensure it is non-negative.
static final int K = 0x7A646E4D; // some large prime.
public int getIndex(int key) {
return Math.abs(key * K % nodes.length);
}
A faster solution is to drop the use of %
use a multiplication and shift. e.g.
public int getIndex(int key) {
return (int) ((key * K & 0xFFFF_FFFFL) * nodes.length >>> 32);
}
What this does is turn key * K
into a fraction and is faster than using %
A simple strategy for hashing an int
value is to multiply by a large constant. If you don't use a constant, you can get very poor collision rates depending on your key distribution. It's is still possible to get poor key distribution, however it is less likely for real data.
NOTE: Unless you know the key cannot be negative, you should use Math.abs
to ensure it is non-negative.
static final int K = 0x7A646E4D; // some large prime.
public int getIndex(int key) {
return Math.abs(key * K % nodes.length);
}
A faster solution is to drop the use of %
use a multiplication and shift. e.g.
public int getIndex(int key) {
return (int) ((key * K & 0xFFFF_FFFFL) * nodes.length >>> 32);
}
What this does is turn key * K
into a fraction and is faster than using %
edited Nov 12 at 14:46
answered Nov 12 at 14:41
Peter Lawrey
440k55558957
440k55558957
1
Seems like you first take the lowest 32 bits after multiplication, and in the end you use only the upper 32 bits?
– Marko Topolnik
Nov 12 at 14:57
do you maybe know where these things are explained ? e.g. how to hash an integer, a string ecc.
– Giacomo
Nov 12 at 15:02
@MarkoTopolnik In the second example, I start with the lower bits of a 64-bit value which after shifting by 32-bits at the end, act like a fraction.
– Peter Lawrey
Nov 12 at 17:09
@Giacomo all data are numbers. You either have a single value likeint
or an array or values likechar
which will require a loop but the principles are the same.
– Peter Lawrey
Nov 12 at 17:10
1
I see now. You use the 32-bit number as a scale factor which is effectively in the range (0,1).
– Marko Topolnik
Nov 12 at 18:04
add a comment |
1
Seems like you first take the lowest 32 bits after multiplication, and in the end you use only the upper 32 bits?
– Marko Topolnik
Nov 12 at 14:57
do you maybe know where these things are explained ? e.g. how to hash an integer, a string ecc.
– Giacomo
Nov 12 at 15:02
@MarkoTopolnik In the second example, I start with the lower bits of a 64-bit value which after shifting by 32-bits at the end, act like a fraction.
– Peter Lawrey
Nov 12 at 17:09
@Giacomo all data are numbers. You either have a single value likeint
or an array or values likechar
which will require a loop but the principles are the same.
– Peter Lawrey
Nov 12 at 17:10
1
I see now. You use the 32-bit number as a scale factor which is effectively in the range (0,1).
– Marko Topolnik
Nov 12 at 18:04
1
1
Seems like you first take the lowest 32 bits after multiplication, and in the end you use only the upper 32 bits?
– Marko Topolnik
Nov 12 at 14:57
Seems like you first take the lowest 32 bits after multiplication, and in the end you use only the upper 32 bits?
– Marko Topolnik
Nov 12 at 14:57
do you maybe know where these things are explained ? e.g. how to hash an integer, a string ecc.
– Giacomo
Nov 12 at 15:02
do you maybe know where these things are explained ? e.g. how to hash an integer, a string ecc.
– Giacomo
Nov 12 at 15:02
@MarkoTopolnik In the second example, I start with the lower bits of a 64-bit value which after shifting by 32-bits at the end, act like a fraction.
– Peter Lawrey
Nov 12 at 17:09
@MarkoTopolnik In the second example, I start with the lower bits of a 64-bit value which after shifting by 32-bits at the end, act like a fraction.
– Peter Lawrey
Nov 12 at 17:09
@Giacomo all data are numbers. You either have a single value like
int
or an array or values like char
which will require a loop but the principles are the same.– Peter Lawrey
Nov 12 at 17:10
@Giacomo all data are numbers. You either have a single value like
int
or an array or values like char
which will require a loop but the principles are the same.– Peter Lawrey
Nov 12 at 17:10
1
1
I see now. You use the 32-bit number as a scale factor which is effectively in the range (0,1).
– Marko Topolnik
Nov 12 at 18:04
I see now. You use the 32-bit number as a scale factor which is effectively in the range (0,1).
– Marko Topolnik
Nov 12 at 18:04
add a comment |
Integer.hashCode(key)
just returns key
as result. You could write:
public int getIndex(int key) {
return key % nodes.length;
}
This way, you don't use Integer.hashCode(key)
.
Without seeing your class ListNode
, you could have a problem with your MyHashMap
structure since you are setting many elements to the same array element. For instance the key 3
and 1003
will be saved in the same node element. You must design MyHashMap
to be a list of list (or an array of list or something similar).
Maybe my question what not so clear. Doing it like I did, Integer.hashCode(key) will return an Integer value which can be everything. Taking % nodes.length this will ensure that this value has now a number which is in the range of my array nodes. If I get a value which corresponds to a cell which is already occupied, I will create (in my methods, this can not be seen in the question) a link to a new node to prevent the collision. So I don't really have the problem you are mentioning.
– Giacomo
Nov 12 at 14:43
Well you must still consider the collisions since they are possible. Of course there is hash function which reduces the collisions, but it was not in your question.
– LaurentG
Nov 12 at 14:46
@Giacomo Note:-1 % nodes.length == -1
– Peter Lawrey
Nov 12 at 14:47
@PeterLawrey i did not mention that keys are potive integers, need to edit it
– Giacomo
Nov 12 at 14:48
add a comment |
Integer.hashCode(key)
just returns key
as result. You could write:
public int getIndex(int key) {
return key % nodes.length;
}
This way, you don't use Integer.hashCode(key)
.
Without seeing your class ListNode
, you could have a problem with your MyHashMap
structure since you are setting many elements to the same array element. For instance the key 3
and 1003
will be saved in the same node element. You must design MyHashMap
to be a list of list (or an array of list or something similar).
Maybe my question what not so clear. Doing it like I did, Integer.hashCode(key) will return an Integer value which can be everything. Taking % nodes.length this will ensure that this value has now a number which is in the range of my array nodes. If I get a value which corresponds to a cell which is already occupied, I will create (in my methods, this can not be seen in the question) a link to a new node to prevent the collision. So I don't really have the problem you are mentioning.
– Giacomo
Nov 12 at 14:43
Well you must still consider the collisions since they are possible. Of course there is hash function which reduces the collisions, but it was not in your question.
– LaurentG
Nov 12 at 14:46
@Giacomo Note:-1 % nodes.length == -1
– Peter Lawrey
Nov 12 at 14:47
@PeterLawrey i did not mention that keys are potive integers, need to edit it
– Giacomo
Nov 12 at 14:48
add a comment |
Integer.hashCode(key)
just returns key
as result. You could write:
public int getIndex(int key) {
return key % nodes.length;
}
This way, you don't use Integer.hashCode(key)
.
Without seeing your class ListNode
, you could have a problem with your MyHashMap
structure since you are setting many elements to the same array element. For instance the key 3
and 1003
will be saved in the same node element. You must design MyHashMap
to be a list of list (or an array of list or something similar).
Integer.hashCode(key)
just returns key
as result. You could write:
public int getIndex(int key) {
return key % nodes.length;
}
This way, you don't use Integer.hashCode(key)
.
Without seeing your class ListNode
, you could have a problem with your MyHashMap
structure since you are setting many elements to the same array element. For instance the key 3
and 1003
will be saved in the same node element. You must design MyHashMap
to be a list of list (or an array of list or something similar).
answered Nov 12 at 14:38
LaurentG
7,87573553
7,87573553
Maybe my question what not so clear. Doing it like I did, Integer.hashCode(key) will return an Integer value which can be everything. Taking % nodes.length this will ensure that this value has now a number which is in the range of my array nodes. If I get a value which corresponds to a cell which is already occupied, I will create (in my methods, this can not be seen in the question) a link to a new node to prevent the collision. So I don't really have the problem you are mentioning.
– Giacomo
Nov 12 at 14:43
Well you must still consider the collisions since they are possible. Of course there is hash function which reduces the collisions, but it was not in your question.
– LaurentG
Nov 12 at 14:46
@Giacomo Note:-1 % nodes.length == -1
– Peter Lawrey
Nov 12 at 14:47
@PeterLawrey i did not mention that keys are potive integers, need to edit it
– Giacomo
Nov 12 at 14:48
add a comment |
Maybe my question what not so clear. Doing it like I did, Integer.hashCode(key) will return an Integer value which can be everything. Taking % nodes.length this will ensure that this value has now a number which is in the range of my array nodes. If I get a value which corresponds to a cell which is already occupied, I will create (in my methods, this can not be seen in the question) a link to a new node to prevent the collision. So I don't really have the problem you are mentioning.
– Giacomo
Nov 12 at 14:43
Well you must still consider the collisions since they are possible. Of course there is hash function which reduces the collisions, but it was not in your question.
– LaurentG
Nov 12 at 14:46
@Giacomo Note:-1 % nodes.length == -1
– Peter Lawrey
Nov 12 at 14:47
@PeterLawrey i did not mention that keys are potive integers, need to edit it
– Giacomo
Nov 12 at 14:48
Maybe my question what not so clear. Doing it like I did, Integer.hashCode(key) will return an Integer value which can be everything. Taking % nodes.length this will ensure that this value has now a number which is in the range of my array nodes. If I get a value which corresponds to a cell which is already occupied, I will create (in my methods, this can not be seen in the question) a link to a new node to prevent the collision. So I don't really have the problem you are mentioning.
– Giacomo
Nov 12 at 14:43
Maybe my question what not so clear. Doing it like I did, Integer.hashCode(key) will return an Integer value which can be everything. Taking % nodes.length this will ensure that this value has now a number which is in the range of my array nodes. If I get a value which corresponds to a cell which is already occupied, I will create (in my methods, this can not be seen in the question) a link to a new node to prevent the collision. So I don't really have the problem you are mentioning.
– Giacomo
Nov 12 at 14:43
Well you must still consider the collisions since they are possible. Of course there is hash function which reduces the collisions, but it was not in your question.
– LaurentG
Nov 12 at 14:46
Well you must still consider the collisions since they are possible. Of course there is hash function which reduces the collisions, but it was not in your question.
– LaurentG
Nov 12 at 14:46
@Giacomo Note:
-1 % nodes.length == -1
– Peter Lawrey
Nov 12 at 14:47
@Giacomo Note:
-1 % nodes.length == -1
– Peter Lawrey
Nov 12 at 14:47
@PeterLawrey i did not mention that keys are potive integers, need to edit it
– Giacomo
Nov 12 at 14:48
@PeterLawrey i did not mention that keys are potive integers, need to edit it
– Giacomo
Nov 12 at 14:48
add a comment |
Well, first of all the hash
is something that is unique or a very rarely repeating value.
Assuming that your values will be evenly distributed you can use the remainder of division as a hash value for your key.
public int get(int key) {
return (-1 ^ key) % nodes.length;
}
Note: ifkey
is negative, this can return a negative number.
– Peter Lawrey
Nov 12 at 14:48
@PeterLawrey Yes, you're right. Fixed the answer.
– ETO
Nov 12 at 14:59
add a comment |
Well, first of all the hash
is something that is unique or a very rarely repeating value.
Assuming that your values will be evenly distributed you can use the remainder of division as a hash value for your key.
public int get(int key) {
return (-1 ^ key) % nodes.length;
}
Note: ifkey
is negative, this can return a negative number.
– Peter Lawrey
Nov 12 at 14:48
@PeterLawrey Yes, you're right. Fixed the answer.
– ETO
Nov 12 at 14:59
add a comment |
Well, first of all the hash
is something that is unique or a very rarely repeating value.
Assuming that your values will be evenly distributed you can use the remainder of division as a hash value for your key.
public int get(int key) {
return (-1 ^ key) % nodes.length;
}
Well, first of all the hash
is something that is unique or a very rarely repeating value.
Assuming that your values will be evenly distributed you can use the remainder of division as a hash value for your key.
public int get(int key) {
return (-1 ^ key) % nodes.length;
}
edited Nov 12 at 14:58
answered Nov 12 at 14:40
ETO
1,589320
1,589320
Note: ifkey
is negative, this can return a negative number.
– Peter Lawrey
Nov 12 at 14:48
@PeterLawrey Yes, you're right. Fixed the answer.
– ETO
Nov 12 at 14:59
add a comment |
Note: ifkey
is negative, this can return a negative number.
– Peter Lawrey
Nov 12 at 14:48
@PeterLawrey Yes, you're right. Fixed the answer.
– ETO
Nov 12 at 14:59
Note: if
key
is negative, this can return a negative number.– Peter Lawrey
Nov 12 at 14:48
Note: if
key
is negative, this can return a negative number.– Peter Lawrey
Nov 12 at 14:48
@PeterLawrey Yes, you're right. Fixed the answer.
– ETO
Nov 12 at 14:59
@PeterLawrey Yes, you're right. Fixed the answer.
– ETO
Nov 12 at 14:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264218%2fwrite-hashfunction-in-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown