Assuming that I have a method foo
:
public Integer foo () { return 1; }
Which of the above to options is lesser expensive? Boxing or unboxing?
assert(1, (int) foo()));
vs.
assert((Integer)3, foo());
I think primitive type variable comparison is more faster than object comparison. also boxing will take more time to create wrapper object. so you should use unboxing in your assertion.