This example demonstrate about Factory method to create Immutable List in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. , In the above code, we have taken listview to add immutable list. Step 3 − Add the following.....
This example demonstrate about How to check edit text values are Anagram or Not in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. , In the above code, we have taken two edit texts to take the data from the user and when .....
This example demonstrate about How to print current activity name in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. , In the above code, we have taken text view to show current activity name. Step 3 − Add the follo.....
This example demonstrate about How to get locale information from Network provider in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. , In the above code, we have taken text view to show locale infomation. Step 3 − .....
The specified string can be split around a particular match for a regex using the String.split() method. This method has a single parameter i.e. regex and it returns the string array obtained by splitting the input string around a particular match for the regex. A program that demonstrates splitting a string is given as follows: Live Demo , , Now let us understand the above program. T.....
The Email address can be validated using the java.util.regex.Pattern.matches() method. This method matches the regular expression for the E-mail and the given input Email and returns true if they match and false otherwise. A program that demonstrates this is given as follows: Live Demo , , Now let us understand the above program. In the main() method, The Email ID is printed. Then the.....
In general, the ? quantifier represents 0 or 1 occurrences of the specified pattern. For example - X? means 0 or 1 occurrences of X. The regex "t.+?m" is used to find the match in the string "tom and tim are best friends" using the ? quantifier. A program that demonstrates this is given as follows: Live Demo , , Now let us understand the above program. The subsequence “t.+?m&rdq.....
The null in Java is a literal of the null type. It cannot be cast to a primitive type such as int. float etc. but can be cast to a reference type. Also, null does not have the value 0 necessarily. A program that demonstrates null in Java is given as follows: Live Demo , , Now let us understand the above program. In the main() method, the String str is initialized as null. Then the val.....
The thread priority determines when the processor is provided to the thread as well as other resources. It can be changed using the method setPriority() of class Thread. There are three static variables for thread priority in Java i.e. MIN_PRIORITY, MAX_PRIORITY and NORM_PRIORITY. The values of these variables are 1, 10 and 5 respectively. A program that demonstrates this is given as follow.....
A thread can be created by implementing the Runnable interface and overriding the run() method. The Main thread in Java is the one that begins executing when the program starts. All the child threads are spawned from the Main thread. Also, it is the last thread to finish execution as various shut-down actions are performed by it. A program that demonstrates this is given as follows: L.....
Sign up now to get your own personalized profile!
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more