所以我有这个变量 long hashvalue
如果某件事属实,我想在其中添加数字。
我有这个数组int arr[3][3]
数字 -1, 1, 0, 0, -1, 1, 0, 0, -1
里面有
我需要这样的东西:
if(array[i][j] == -1){
//add digit 2 to hashvalue
} else if(array[i][j] == 1){
//add digit 1 to hashvalue
} else if(array[i][j] == 0){
//add digit 0 to hashvalue
}
哈希值 = 210021002
最佳答案
您可以简单地为哈希值创建一个字符串,然后通过 +(或 +=)运算符将数字添加到该字符串中。要从字符串接收长对象,可以使用 Long.parseLong() 函数。
String hashvalue = "";
// Add your digits to the String here
hashvalue += "1";
// Convert the String to a long
long finalHashvalue = Long.parseLong(hashvalue);
关于java - 如何向长值添加数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31372277/