Question

I was looking around the Android framework documentation, and one thing caught my eye. The setIs24HourView method of TimePicker uses the wrapper class Boolean, not the primitive type boolean.

I was just wondering, could there be a specific reason to use the wrapper class there? Can it do any benefit or could it just be a developer accidentally pressing Shift a little too long? And could/should it be reported as a bug (indeed an extremely tiny one, because of auto-boxing, but still one)?

Était-ce utile?

La solution

In general, you want to use Boolean instead of boolean when your API allows the "unknown" state, for which you could allow passing null.

In this case, however, there is no "unknown" state, because the corresponding getter is declared with the primitive boolean:

public boolean is24HourView ()

I would definitely report this as a bug.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top