Tìm hiểu về các phép so sánh trong java


Preface


Trong java có 3 kiểu so sánh đặc trưng như sau:

+ Sử dụng toán tử == : return Boolean

Primitive thì so sánh giá trị thực,

Reference đã xây dựng sẵn Sử dụng ô nhớ địa chỉ để xét với nhau.

Reference tự định nghĩa So sánh bộ nhớ địa chỉ.


+ Sử dụng hàm equals() : return Boolean

Primitive so sánh giá trị thực,

Reference đã xây dựng sẵn sử dụng giá trị trực tiếp

Reference tự định nghĩa so sánh ô nhớ nếu ko override.


+ Sử dụng hàm compareTo(): dùng cho sort trả về 1 giá trị số.

Primitive so sánh giá trị thực,

Reference đã xây dựng sẵn sử dụng giá trị trực tiếp,

Reference tự định nghĩa ko có giá trị phải implement Comparable.


Start


You can view detail lecture here:

https://github.com/nguyenthinhit996/sharefullcode/blob/java/Learn%20Java/Java%20Basic/T%C3%ACm%20hi%E1%BB%83u%20v%E1%BB%81%20c%C3%A1c%20ph%C3%A9p%20so%20s%C3%A1nh%20trong%20java.pdf






Thank you for all

This section is non commercial mainly sharing and advance knowlage for java.This tutorials has referenced document from the list below if you has complain for license, i will remove all from internet.

0 comments :

Post a Comment

Cancel Reply

About Me

My photo
Tân An, Long An, Vietnam
Hello everyone, I love programming, I love making friends with people all over the world.