Is it possible to compare various strings with the help of == operator? What are the risks involved?



Is it possible to compare various strings with the help of == operator? What are the risks involved?..

Answer / Raj Kapoor

It is possible to compare strings using the '==' operator, but doing so can lead to unexpected results. The '==' operator checks if both objects refer to the same memory location (i.e., if they are instances of the same String object). This may not always be desirable or accurate as it does not verify whether the content of both strings is identical. Using the equals() method for string comparison is strongly recommended.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What makes a function well defined?

1 Answers  


Write a program in java to find the maximum and minimum value node from a circular linked list.

1 Answers  


What is == in java?

1 Answers  


using equals method overriding which objects are compared?i.e same class objects or other class objects?Explain me.

4 Answers  


What is a java lambda expression?

1 Answers  


What is an empty string in css?

1 Answers  


What is considered an anti pattern?

1 Answers  


What is functional interface in java?

1 Answers  


How do you sort arraylist in descending order?

1 Answers  


What is the difference between assignment and initialization?

1 Answers  


How is a structure different from array ?

1 Answers   Amdocs,


What is public/private protected in java?

1 Answers  


Categories