Home >Java >javaTutorial >How to compare data in java

How to compare data in java

王林
王林forward
2023-05-10 10:43:161774browse

Explanation

1. Compare basic type ==. It is recommended to compare equals or compareTo for the comparison object value.

First of all, data in Java is stored in the JVM, and basic type data is stored in the local variable table of the JVM, which can also be understood as the so-called "stack".

2. You can use == to compare whether the values ​​of type int are equal, but please note that int and Integer are completely different. One is a basic type and the other is an object.

Examples

Compare basic type values

int i = 11111111;
int j = 11111111;
System.out.println(i == j);

What collection classes are there in Java

Collections in Java are mainly divided into four categories :

1. List: ordered and repeatable;

2. Queue: ordered and repeatable;

3. Set: not possible Repeat;

4. Map mapping: unordered, unique keys and non-unique values.

The above is the detailed content of How to compare data in java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete