Question: I have developed a website for PC using asp.net MVC5. Now trying to develop a mobile supported anonymous access web page for same website using asp.net MVC5. I created a new project for this and downloaded jQuery.Mobile.MVC from Nuget console. This added mobile layout in the project with the JS code 

```js
$(document).ready(function () {
    $.mobile.ajaxEnabled = false; 
});

```

I just added a new view with this mobile layout and added few label controls to see how it works. It throws below error

JavaScript runtime error: Unable to set property 'ajaxEnabled' of undefined or null reference

Do I have to add any other libraries? This is my first mobile page. It would be great if you are help with some good tutorials

I have included jquery.mobile.js references

Thanks

Answer: 
There are good reasons to makes the primitive wrappers final.

First, note that these classes get *special treatment* in the language itself - unlike any normal classes, these are recognized by the compiler to implement auto(un)boxing. Simply allowing subclasses would already create pitfalls (unwrapping a subclass, performing arithmetic and wrapping back would change the type).

Also, wrapper types *can* have shared instances (e.g. look at Integer.valueOf(int)) requiring that an instance of a wrapper is strictly immutable. Allowing subclasses would open up a can of worms where immutability can no longer be assured, forcing robust code to be written as if the wrappers were mutable, leading to defensive copies, wasting memory and CPU time and also creating issues with their usefulness in multi-threaded scenarios.

Essence: wrapper types need to be immutable to ensure uniform capabilities across all instances; immutablility being an important part of their known properties. And to guarantee immutability, the types *need* to be final.

If you need added functionality, implement it as utility class like you would do for primitives (see java.lang.Math for example).

---

Edit: To address the case made for "the classes needn't" be necessary final to ensure immutability. Strictly speaking this is true, the wrappers *could* be designed as non-final classes, only making *all* of the methods final. That would alleviate most of the pitfalls, but it leads to another issue: compatibility with new java versions. Imagine you decided to create your own subtype MyInteger sporting a new method, e.g. "Integer decrement()". Everything works fine, until... in Java 20 the language designers decide to add a decrement() method to the API (which would be *final* as discussed above). Bam, your class no longer loads, since it attempts to overwrite a final method.
They need to be immutable. And a key feature of correctly implemented immutability is it can't be extended. If you could extend you could do this:

```
class MyInteger extends Integer
{
    private int myOverrideValue;

    @Override
    public int intValue() {
      return myOverrideValue;
    }

    public void setIntValue(int value) {
      myOverrideValue = value;
    }
}

```

Now I can pass around objects of the mutable type `MyInteger` to classes and code that expects `intValue` to not change.