![]() ![]() The given string is equal to the specified object or not? false Using the equals() method, we are trying to determine whether the given string is equal to the specified object “Hello” or not.įollowing is the output of the above program − In the following example, we are creating a string literal with the value “HelloWorld”. If the given string value is the different from the specified object value, the equals() method returns false. The given string is equal to the specified object or not? true On executing the above program, it will produce the following result − ("The given string is equal to the specified object or not? " + str.equals(obj)) Using the equals() method, we are trying to determine whether the given string is equal to the specified object “Java” or not. ![]() In the following program, we are instating the String class with the value “Java”. If the given string value is the same as the specified object value, the equals() method returns true. This method returns true if the given object represents a String equivalent to this string, else false. anObject − This is an object to compare with this String.Syntaxįollowing is the syntax of the Java String equals() method − It does not throw any exception while comparing or checking whether the string is equal to the specified object or not. The equals() method accepts an object as a parameter which is comparable. It returns true if the string instances contain the same characters in the same order else, it returns false. The Java String equals() method is used to check whether the current string is equal to specified object or not. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |