How-to articles, tricks, and solutions about JAVA
Adding header for HttpURLConnection
To add a header to an HTTP request using HttpURLConnection, you can use the setRequestProperty method.
Android changing Floating Action Button color
To change the color of a Floating Action Button (FAB) in Android, you can use the setBackgroundTintList() method and pass it a color state list.
android on Text Change Listener
In Android, you can use a TextWatcher to listen for changes to the text in a TextView or EditText view.
Android SDK installation doesn't find JDK
If the Android SDK installation is unable to find the JDK (Java Development Kit), it could be because the JDK is not installed or is not installed in the default location.
Android Split string
To split a string in Android, you can use the split() method of the String class.
Any shortcut to initialize all array elements to zero?
To initialize all elements of an array to zero in Java, you can use the Arrays.fill method from the java.util package.
Append a single character to a string or char array in java?
To append a single character to a string or char array in Java, you can use the + operator or the concat method for strings, or you can use the Arrays.copyOf method for char arrays.
ArrayList of int array in java
To create an ArrayList of int arrays in Java, you can use the following syntax:
Avoiding NullPointerException in Java
A NullPointerException is a runtime exception that is thrown when an application attempts to use an object reference that has a null value. To avoid this exception, you need to make sure that the object reference is not null before you use it.