Java performance: true vs. Boolean.TRUE
Which of the following is better in terms of performance and efficient memory usage? Boolean isItTrue(arg){ return Boolean.TRUE; } boolean isItTrue(arg){ return Boolean.TRUE } Boolean isItTrue(arg){ return true; } boolean isItTrue(arg){ return true; } It should be faster and easier to work with primitive types, but on the other hand, when using a reference to a static object, no new value is created. Or is it optimized on compiler level and all true and false are replaced by references to the static objects to save memory? Firstly, the performance advantage of using any one over the others is