-3

what does list1=list2 and list1==list2 mean when we use ArrayLists?

ArrayList <String> list1, list2;
list1=new ArrayList<>(); list2=new ArrayList<>();
Fancy
  • 11
  • 2
  • 2
    `=` is the assignment operator and is assigning a reference of `list2` to `list1` and `==` equality operator and checks for referential equality between the two lists. – GBlodgett Oct 21 '18 at 18:07
  • Possible duplicate of [Java Compare Two Lists](https://stackoverflow.com/questions/2762093/java-compare-two-lists) – Jan Oct 21 '18 at 18:42

1 Answers1

1

In Java, a single equal sign = is used to assign values to variables to be used later in your code, this is why it is called the assignment operator.

Two equal signs == is a comparative operation between two values which returns a Boolean. For instance 1 == 1 will return true, but I would be careful when using this operation with objects and would suggest using the equals() or compare() method.