Why does the android Bitmap class not use the new keyword?

As the title says, why does it not use the new keyword? Why do we have to create any new bitmaps in a static way?


This is a design choice. The designers deemed it non-sensible to allow new Bitmap instances to be created without using one of the many (static) factory methods.

One advantage is that it allows the factory methods to - if such is appropriate - return the same instance across multiple calls. Note that some Bitmaps returned are guaranteed to be immutable, and thus safely re-usable (which can avoid wasting memory with duplicated image data).

Use one of the Bitmap.createBitmap factory method overloads to obtain a (possibly but not guaranteed to be new) Bitmap object.

Using new Bitmap() is not allowed because the Bitmap constructor is is private, such that only the factory methods can access it directly.

Need Your Help

Find recurrence relation of this algorithm?

algorithm big-o recurrence

Assuming n=B-A+1, I need to derive the recurrence relation of this algorithm:

How do I modify my Web API server code to add a Access-Control-Allow-Origin' header?

jquery asp.net-web-api xmlhttprequest localhost cors

I have a Web API app and am able to call its REST methods with a Windows forms util; I want to call them from an HTML/jQuery util, too, and tried to do so by following along with this tutorial.