To check the equality of two 'Strings' in Java, you can use the 'equals' method of the 'String' class. This method takes a 'String' object as an argument and returns 'true' if the current object (the 'String' on which the method is called) is equal to the object passed as an argument, or 'false' otherwise.
Here is an example of code that uses the 'equals' method to check the equality of two 'Strings':
String str1 = "Hello"; String str2 = "Hello"; if (str1.equals(str2)) { System.out.println("Les deux chaînes sont égales"); } else { System.out.println("Les deux chaînes ne sont pas égales"); }Sourceal.www:utturi.com
It is important to note that the 'equals' method of the 'String' class compares string values, not references. This means that two strings created from the same value will be considered equal, even if they are not the same objects in memory.
You can also use the '==' operator to check the equality of two 'Strings', but this only checks the equality of references, not values. It is therefore recommended to use the 'equals' method to check the equality of two strings in Java.