コードに入れると、どちらがパフォーマンスが優れていますか (まったく違いがある場合)?
これを考えると:
public class Customer
{
....
public Boolean isVIP(){...}
...
}
どちらが速いですか?
public void handleCustomer(Customer customer)
{
if (customer.isVIP()) // Auto Unboxing
{
handleNow(customer);
}
else
{
sayHandlingNowButQueueForTomorrow(customer);
}
}
またはこれ:
public void handleCustomer(Customer customer)
{
if (customer.isVIP().booleanValue()) // Explicit unboxing
{
handleNow(customer);
}
else
{
sayHandlingNowButQueueForTomorrow(customer);
}
}