How to distinguish between == and .equals() method in Java

Generally speaking, equals() and "==" operator are used to compare whether two objects are equal, but there are many differences between the two: The main difference is that .equals() is a method, == is an operator. Use == to compare references, referring to whether they point to the same memory address. Use .equals() to compare the content of objects, comparing values. If .equals is not overridden, it will default to calling the nearest superclass to override this method.

2018 Year-end Summary

It’s the end of the year, so I’m going to write a little summary of 2018. This year, there have been losses and gains. The loss was the failure of a relationship that didn’t work out, and the gain was a general improvement in my personal quality. Let’s not dwell on what’s lost. Let’s talk about the gains. The gains can be divided into three aspects: physical, technical, and financial.

Java Collection Expansion

Collection Expansion ArrayList The default capacity of ArrayList is 10, so if you need to handle large amounts of data with ArrayList, you need to use the method of explicitly specifying the capacity. This can reduce unnecessary expansion operations. The main reason is that the expansion operation of ArrayList requires extra space, and it uses the Arrays.copyOf method for copying: 1 2 3 4 5 6 7 8 9 10