answersLogoWhite

0

The equals method in Strings is used to check if two strings are the same.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What method returns the uppercase equivalent of a string?

The toUpperCase() method returns the uppercase equivalent of a string.


How do you separate a word using a string method?

The string class has a split() method which takes a regex pattern and splits the string and returns an array.


Can you write the code to compare 2 string objects in Java?

In java, the String object has a compareTo() method. The method returns an int. If the int is less than zero, the first string is less than the second. If the int is greater, the first is greater than the second. If the int is zero, the two strings are equal.


What are some ways in order to perform String comparison in Java?

String comparison in Java features four ways. These ways are String comparison using equals method, equalsIgnoreCase method, CompareTo method, and CompareToIgnoreCase method.


How do you get odd ascii letters from a given string using string copy?

there is no such method using string copy


What are the explanation steps for palindrome program?

If you want to check whether a string is a palindrome, you can reverse the string (for example, the Java class StringBuffer has a reverse() method), and then compare whether the two strings - the original string and the reverted string - are equal. Alternately, you could write a loop that checks whether the first character of the string is equal to the last one, the second is equal to the second-last one, etc.; that is, you have a counter variable (in a "for" loop) that goes from zero to length - 1 (call it "i"), and compare character #i with character #(length-i-1) inside the loop.


What method that returns string representation of the contents of the variable?

Since the question is in the Java category: in Java, the method is called toString(). This method will automatically be invoked if you implicitly convert an object to String type, for example: "The answer is: " + myObject In this example, the String concatenation (the plus sign) forces the object, myObject, to type String - to do this, the object's toString() method will be called.


What method of the string class would help you check if a string ends with a certain sequence of characters?

str.endsWith(string)


What is the constant string length method?

To get the length of the string we use length property. The length property returns the length of a string (number of characters we use).If the string is empty, length of the string will be 0. Syntax: string.length Hope this helps.


Write a method header for a method named find that takes a String and a double as parameters and returns an integer?

int find(String str, double d);


How do you use indexOf in java?

indexOf is a method of the String class. Since the indexOf method is overloaded, I will be using the indexOf(String str) version in this example. According to the API Documentation, this method "Returns the index within this string of the first occurrence of the specified substring." So, if you wanted to find the position of the letter 'v' in the String 'Java' and print it out, you would do this: String str = "Java"; int i = str.indexOf("v"); System.out.println(i); If the character you passed in the indexOf method does not exist in the String, indexOf would return a -1 (negative one).


How do you define a method with method attributes?

Access Datatype1 MethodName(Datatype TemporaryName, Datatype TemporaryName) { return Datatype1; } Which could look like: public String Hello(String firstAttribute, String secondAttribute ) { return firstAttribute; }