GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — toBeTopJavaer/basics/java-basic/enum-compare.md at master · yangjunhui710/toBeTopJavaer

Expand file tree

/

enum-compare.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
7 lines (4 loc) · 362 Bytes
/

enum-compare.md

Copy path

File metadata and controls

7 lines (4 loc) · 362 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
java 枚举值比较用 == 和 equals 方法没啥区别,两个随便用都是一样的效果。
因为枚举 Enum 类的 equals 方法默认实现就是通过 == 来比较的;
类似的 Enum 的 compareTo 方法比较的是 Enum 的 ordinal 顺序大小;
类似的还有 Enum 的 name 方法和 toString 方法一样都返回的是 Enum 的 name 值。
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.