一直没怎么注意,今天遇到了,还真没不知道,
public static int hash(String key, int dim)
{
double d = Math.pow(2.0D, dim);
int m = (int)Math.floor(d);
String t = m + key;
t = StringUtils.encodeMD5(t);
char[] chars = t.toCharArray();
int hashval = 0;
for (int i = 0; i < chars.length; i++) {
hashval += chars[i];
}
int pos = hashval % m + 1;
return pos;
}
char[i]会自动转换成ASCII值,例如字母a对应的ASCII值为97
最后
以上就是踏实电源最近收集整理的关于char类型转换成int类型,字母会取ASCII值的全部内容,更多相关char类型转换成int类型内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复