Yes! That works, is there any reasoning behind that or is it just the way it is?
Aha. Yes, you need to brush up on your understanding of object-oriented languages and the difference between objects and primitive types.
A primitive type is just a piece of data (almost always resolves to just a number). Like an integer, a floating point number, a character (which is really just represented as a number anyway), a bool (true/false, which can also be represented as a number).
You can't really do much with primitive types other than assign them to variables, copy them, manipulate them mathematically.
Then there are Objects, which are instances of Classes. Objects can contain data (which can be instances of other objects, or a bunch of primitive types), they can have methods, constructors, destructors, all kinds of code.
It's like the difference between a simple number and a dialog. A number is a number. You can't do much with it. You can't contain data within it. A dialog is far more complicated -- they can be created, destroyed, displayed, resized, they can contain data, messages, etc.
When a method is expecting some kind of object, and you give it a number, it doesn't like that. That's why you were getting an error before.
The solution? Java provides a class called Integer, which encapsulates an integer. (It's an object that contains exactly one piece of data -- an integer number). That's what you're doing in the version of the code that works -- you are creating a new object which contains the integer you want. This satisfies the method that expected an object.
So when you have a method that expects an object, and the thing you're actually trying to send it is a number, you just create a new object that contains that number, and then you can pass it to the method.