2 days ago
Great point, Desislav Petrov! 🚀 For most collections like ArrayList, .size() is indeed a constant-time operation (O(1)). But for certain implementations, like LinkedList, calling .size() inside a loop can be costly because it requires traversal (O(n)). The impact depends on the data structure used.
I appreciate your feedback! I’ve now updated that section in my article