The formal explanation , as you probably already understand, is that the two functions have different signatures (as Andrew Tobikko already pointed out), so you cannot override the other.
So, I suppose that by asking this question, you really want to ask, โwhy is this so,โ or โwhy the compiler cannot figure out what to do to let me do this.โ
So, the practical explanation is as follows:
This is because you might have some method somewhere (some class not related to the class) that takes SuperClass as a parameter and tries to call its method1() as follows:
public void someMethod( SuperClass s ) { s.method1( 7 ); }
When the compiler finds this, it will pass 7 as a parameter to method1() , it will not go through wrapped 7 . However, s cannot be an instance of SuperClass , it can be an instance of SubClass , for example:
someMethod( new SubClass() );
This is true because the PLO has a principle known as the Liskov Substitution Principle , which states that
if S is a subtype of T, then objects of type T can be replaced with objects of type S (i.e. objects of type S can replace objects of type T) without changing any desired properties of this program (correctness, task performed, etc.) .
This is the same principle that allows you to assign new ArrayList<String>() variable of type List<String> , and without it, nothing will work in OOP.
So, the compiler would have to pass a simple primitive 7 , but the SubClass receiver method SubClass expect a wrapped 7 , and that didn't work. Thus, the language indicates that an implicit conversion of this kind is not valid to ensure that such meaningless situations may not occur.
Amendment
You may ask, "Why doesnโt this work?" The answer is that primitives in java correspond to machine data types of the main equipment, and wrapped primitives are objects. So, on the machine stack, a 7 will be represented by a machine word with the value 7 , while wrapped 7 will be a pointer to an object that contains wrapped 7 , so it will be represented by a machine word containing the address of this object, and it will be something like 0x46d7c8fe .