My Work Journal
A journal of Programming, Technology and Management notes
Monday, June 29, 2009
Comparison in Enums
Tip on Enums
Instead of using id to do equality comparisons for enums, use the enum itself.
Example: Instead of
if (selectedTab.getId() == Tab.SITES.getId()) {
use:
if (selectedTab.equals(Tab.SITES)) {
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment