1

I am learning android. I never used Bit flags in my life. So I bit explored to understand better. And I came across this article.

http://eddmann.com/posts/using-bit-flags-and-enumsets-in-java/

As the author suggests EnumSet is way more helpful than bit flags. But still why android framework used lot of Bit flags instead of EnumSets. Is there any specific reason to chose this hard way?

Manoj
  • 5,707
  • 19
  • 56
  • 86

1 Answers1

1

Performance. I'm about to have CommonsWare downvote and disagree (we've argued about this on the site at least once before), but enums are strings. Bit fiddling is far more efficient. Constant string comparisons are inefficient In frequently run code like the framework, its best to avoid inefficiencies by design. Java just relly screwed up on enums by making them strings instead of integers.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127