Using int vs Integer

the Integer class is provided so that values can be boxed/unboxed in a pure OO manner. use int where appropriate unless you specifically need to use it in an OO way; in which case Integer is appropriate. Java Int vs Integer However, very different things are going on under the covers here. An int is … Read more

Why doesn’t Kotlin allow to use lateinit with primitive types?

For (non-nullable) object types, Kotlin uses the null value to mark that a lateinit property has not been initialized and to throw the appropriate exception when the property is accessed. For primitive types, there is no such value, so there is no way to mark a property as non-initialized and to provide the diagnostics that … Read more

How can you pass multiple primitive parameters to AsyncTask?

Just wrap your primitives in a simple container and pass that as a parameter to AsyncTask, like this: private static class MyTaskParams { int foo; long bar; double arple; MyTaskParams(int foo, long bar, double arple) { this.foo = foo; this.bar = bar; this.arple = arple; } } private class MyTask extends AsyncTask<MyTaskParams, Void, Void> { … Read more

tech