爲什麼可以將一個原語傳遞給一個接受對象的方法?基元變成了一個物體嗎?像int = Integer和boolean = Boolean?爲什麼我可以將一個原語傳遞給一個需要一個對象的方法?
我可以調用下面的函數:
hash(41, 0);
public static int hash(int seed, Object object)
{
int result = seed;
if(object == null)
{
return hash(result, 0);
}
else if(!isArray(object))
{
result = hash(result, object.hashCode());
}
else
{
int length = Array.getLength(object);
for(int index = 0; index < length; ++index)
{
Object item = Array.get(object, index);
// prevent looping if item in array references the array itself
if(!(item == object))
{
result = hash(result, item);
}
}
}
return result;
}
你是否使用散列(41,0)調用散列(int seed,Object object)? – UDPLover