Complete the code to compare two strings for equality.
String a = "hello"; String b = "hello"; boolean result = a.[1](b);
The equals method compares the content of two strings for equality.
Complete the code to compare two strings ignoring case differences.
String a = "Hello"; String b = "hello"; boolean result = a.[1](b);
equals which is case-sensitive.The equalsIgnoreCase method compares two strings ignoring case differences.
Fix the error in the code to correctly compare two strings.
String a = "test"; String b = new String("test"); if (a.[1](b)) { System.out.println("Equal"); } else { System.out.println("Not equal"); }
Use equals to compare string contents, not == which compares references.
Fill both blanks to create a map of strings to their lengths, but only include strings longer than 3 characters.
Map<String, Integer> lengths = words.stream()
.filter(word -> word.[1]() > 3)
.collect(Collectors.toMap(word -> word, word -> word.[2]()));length without parentheses which is a field for arrays, not strings.size() which is for collections, not strings.The length() method returns the length of a string. It is used both to filter and to get the length value.
Fill all three blanks to create a map of uppercase strings to their lengths, including only strings longer than 4 characters.
Map<String, Integer> result = words.stream()
.filter(word -> word.[1]() > 4)
.collect(Collectors.toMap(word -> word.[2](), word -> word.[3]()));length without parentheses.toLowerCase() instead of toUpperCase().Use length() to filter by length, toUpperCase() to convert strings to uppercase for keys, and length() again to get the length values.
