In this episode, we'll focus on the comparison of sequence of characters. Be careful, the operators "==" for the equality and "!=" for the non-equality, when applied on two variables of String type, test if the two variables have a reference (or not) to the same memory addresses, which contains a sequence of characters. Additionally, with the use of the String literal pool, this causes a number of subtleties, that we are going to see in this example. Here I have the declaration and the initialization of a variable "s1" that will reference the sequence of characters "abc". Here, "s2" is also initialized with the sequence "abc". This sequence "abc" is part of the String literal pool. That's why "s1" and "s2" have the same reference on the same sequence of characters. Here, I declare a varialbe "s3" in which I copy the content of "s2". "s2" contains a reference to this sequence "abc" and therefore "s3" will now also contain a reference to this same sequence "abc". I now do this last assignment. To "s4", I'll assign the concatenation of the variable "s1", which is "abc", and the empty sequence, which I'll represent like this. I finally simply obtain the sequence "abc". And "s4" will get a reference to this sequence "abc". But note that this "abc" isn't the same as this one. More precisely, they aren't in the same memory location and this reference is different from these references. So why exactly? That's because "s1", "s2" and "s3" were directly initialized from String literals, while that isn't the case for "s4". We can verify that by executing these instruction lines. This "println" prints the result of this condition. This condition is true when "s1" is equal to "s2", that is when the reference in "s1" is the same as the reference in "s2". And in the diagram we can see that it is indeed the case. Therefore this condition is true. "s2" is indeed equal to "s3" as "s2" and "s3" both contain a reference to this same sequence of characters "abc". This condition is true. And as here there's a "&", this whole condition is true. We'll therefore print "true", as we can verify it in practice. When I execute this instruction line, which prints the sequence of characters "s4", we'll get the sequence "abc" printed, which is this sequence here. Let me remind you that when we execute the function "print" or "println" on a String variable, we don't print the reference, but the sequence of characters that is referenced, which is useful. Now, if I print the value of this condition, which is "s1" = "s4", "s1" contains this reference, "s4" contains this reference, which are different references, so the conditon is false. And this "println" will print "false", even if the two sequences corresponding to "s1" and "s4" are the same, are both "abc". So it is indeed the references that are compared. But in practice we want to compare the sequences of characters themselves rather than their references. And to achieve this, there's a specific process to compare Strings. To effectively compare two sequences of characters, we have the function "equals". For example, to compare two variables "chaine1" and "chaine2", I'll call my function "equals" like this. So, first the name of the first variable. followed by a point, followed by the name of the function "equals", and followed by the second variable that we want to compare, as an argument to "equals". This "equals" function will return either "true", if "chaine1" and "chaine2" correspond to the same sequence of characters and don't necessarily have the same reference; or "false", if the two sequences are different. For example, here I declared a variable "s1" that contains a reference to a sequence of characters "abc", a variable "s2" that contains a reference to a sequence "aBc", but with "b" in capital letter, and here a variable "s4" that is initialized to the result of the concatenation of "s1" and the empty sequence. "s1" corresponds to the sequence "abc". When I concatenate "abc" with the empty sequence, I simply get the sequence "abc". And "s4" will contain a reference to this sequence "abc". We saw in a previous slide that the references contained in "s1" and "s4" were different, so I can't directly compare "s1" and "s4" by using the character "==". However, I can use the function "equals". That's what I'm doing here, I compare "s1" and "s4" by calling the functrion "equals" and I can verify that this time I do obtain "true". Because the sequence of characters are exactly the same, the characters "abc" are the same. If I now test if "s1" is equal to "s2", it turns out that the function "equals" makes the difference between lowercase and uppercase letters, and as 'b' is lowercase here, and this 'B' is uppercase, the function will return "false". That was the comparison of two sequence of characters. In the last video, we'll see what else we can do on sequences of characters.