.equal() in java code example Example: java equal method if(bob.equals("Sam")){ // Checks if strings are equal. // code }