java. util. What is the runtime of equals() in arrays?
•
Java
As the title shows, Java util. What is the runtime of equals() in arrays?
For example, if you compare two ints [], does it loop through each element in the array, so o (n)? For all equals () in equals () of each class in Java, we can assume that the runtime is always o (n)?
thank you.
Solution
The default equals can represent object equals. Arrays. Equals () is usually what you really want
Yes, it's a hint of what the source is
For some sets, this is true, but for tree sets, it can be o (n log n) The worst case of HashMap is that O (n ^ 2) has no meaning for non sets
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码