If this problem is expanded, it will be complicated, including how to store the memory, how to point to the ah.

Just to give you a tip, Java’s basic data types are the following, which can be computed directly with the CPU.

  • Integer types: byte, short, int, long
  • Floating point types: float, double
  • The character type is char
  • Boolean type: Boolean

The process of converting these basic data types into objects is what we call wrapping. The most common one is String, and a lot of people ask about these types of conversions in interviews, but it’s perfectly normal.

A lot of time in Java programming involves type conversion.

== compares the (heap) memory addresses of objects stored in the variable (stack) memory to determine whether the addresses of two objects are the same, that is, whether they are the same object. Since the basic types are computed by the CPU, it is easy to understand that comparing addresses yields results. Since the basic types are computed by the CPU, it is easy to understand that comparing addresses yields results.

After a primitive type is converted to an object, it makes no sense to use == to compare addresses, because different objects use different addresses, which is fine.

conclusion

  • So the conclusion is if the object doesn’t work= =Compare values using equals only.
  • Java primitives all start in lowercase, wrapper types all start in uppercase, easy to remember.
  • In the case of wrapper type comparisons, it is not always necessary to compare equals directly in actual programming because empty object exceptions are possible, and Apache Commons or Guava are usually used to compare.

www.ossez.com/t/java-stri…