AP® Computer Science A glossary

equals

Course: AP® Computer Science A Shows up in: Unit 1: Using Objects and Methods

The String method equals(Object other), which returns true if both strings have the same sequence of characters.

Appears in the course and exam description (CED): 1.15.B.2

equals is case-sensitive: "Cat".equals("cat") is false. The == operator only checks whether two references point to the same object.

String a = "go";
String b = new String("go");
System.out.println(a.equals(b));
System.out.println(a == b);

Output:

true
false
Learn it properly, with a checkpoint 1.15 String Manipulation

Related terms

Was this page helpful?

No names are ever shown, and every public comment is checked by us first. Please do not include personal details. To get a reply, email [email protected].

↑ Top

Enlarged view of the selected figure