WEB DEVELOPER SITE
PHP7
 

Java String equals() Method



This method compares this string to the specified object.


Syntax

Here is the syntax of this method โˆ’

public boolean equals(Object anObject)

Parameters

Here is the detail of parameters โˆ’

  • anObject โˆ’ the object to compare this String against.

Return Value

  • This method returns true if the String are equal; false otherwise.

Example


public class Test {

   public static void main(String args[]) {
      String s = "Strings are immutable";
      char result = s.charAt(9);
      System.out.println(result);
   }
}

Run example ยป