Java String Equals Example UPDATE

Yatin B.Yatin B.
1 min read

Date: 2023-07-19

This article explains the difference between Java's equals() method and the == operator when comparing strings. equals() checks for equality of character sequences (case-sensitive), while == compares memory addresses. The article also covers equalsIgnoreCase(), which performs a case-insensitive comparison, and the intern() method, which places strings in a pool for memory optimization. String literals are stored in a string pool, while new String() creates new objects in the heap. Incorrect results in the original article regarding the equals() method are noted.

Read more: https://examples.javacodegeeks.com/java-string-equals-example/

0
Subscribe to my newsletter

Read articles from Yatin B. directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yatin B.
Yatin B.