- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String compare by == operator in Java
You can compare two strings using == operator. But, it compares references of the given variables, not values.
Example
public class Sample { public static void main(String args[]){ String str1 = "hello"; String str2 = "hello"; System.out.println(str1 == str2); } }
Output
true
- Related Articles
- String compare by equals() method in Java
- String compare by compareTo() method in Java
- Difference between Relational operator(==) and std::string::compare() in C++
- String Concatenation by + (string concatenation) operator.
- Java Program to use == operator to compare enums
- How do we compare String in Java
- How to compare String equality in Java?
- How to Compare two String in Java?
- Java string concat() method vs "+" operator
- How to compare two dates in String format in Java?
- Java Program to compare string using compareTo() method
- Compare Two Different Files Line by Line in Java
- Java Program to Differentiate String == operator and equals() method
- Why is operator overloading not supported by java?
- String Formatting Operator in Python

Advertisements