Home > Java > JavaBase > body text

How to determine whether strings are equal in java

王林
Release: 2019-11-19 09:37:05
Original
2802 people have browsed it

How to determine whether strings are equal in java

Method:

boolean equals(object obj);
Copy after login

Test:

First, create a class with a main method

How to determine whether strings are equal in java

Then define two string variables a and b with equal values, both of which are "baidu ABC me"

How to determine whether strings are equal in java

Then use boolean equals(object obj); to determine whether the two strings are equal:

You can see that the returned value is true, indicating that they are equal

How to determine whether strings are equal in java

In order to verify and complete, Define another string variable c, assign the value "asd", and continue the comparison

How to determine whether strings are equal in java

After running, you can see that the running result is false, indicating that they are not equal

How to determine whether strings are equal in java

Recommended tutorial: Java tutorial

The above is the detailed content of How to determine whether strings are equal in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!