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

Converting characters to integers in Java

Character.getNumericValue(c) The java.lang.Character.getNumericValue(char ch) returns the int value that the specified Unicode character represents. For example, the character ‘\u216C’ (the roman numeral fifty) will return an int with a value of 50. The letters A-Z in their uppercase (‘\u0041’ through ‘\u005A’), lowercase (‘\u0061’ through ‘\u007A’), and full width variant (‘\uFF21’ through ‘\uFF3A’ and ‘\uFF41’ through … Read more

Is an array a primitive type or an object (or something else entirely)?

There is a class for every array type, so there’s a class for int[], there’s a class for Foo[]. These classes are created by JVM. You can access them by int[].class, Foo[].class. The direct super class of these classes are Object.class public static void main(String[] args) { test(int[].class); test(String[].class); } static void test(Class clazz) { … Read more