Arushi has Published 141 Articles

Role of Matcher.matches() method in Java Regular Expressions

Arushi

Arushi

Updated on 30-Jun-2020 08:32:13

147 Views

The method java.time.Matcher.matches() matches the given region against the specified pattern. It returns true if the region sequence matches the pattern of the Matcher and false otherwise.A program that demonstrates the method Matcher.matches() in Java regular expressions is given as follows −Example Live Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo { ... Read More

Create a Read-Only Collection in Java

Arushi

Arushi

Updated on 30-Jun-2020 08:28:36

194 Views

An example of a read-only collection can be an unmodifiable ArrayList. The unmodifiable view of the specified ArrayList can be obtained by using the method java.util.Collections.unmodifiableList(). This method has a single parameter i.e. the ArrayList and it returns the unmodifiable view of that ArrayList.A program that demonstrates this is given ... Read More

Loop through the Vector elements using a ListIterator in Java

Arushi

Arushi

Updated on 30-Jun-2020 08:21:33

173 Views

A ListIterator can be used to traverse the elements in the forward direction as well as the reverse direction in a Vector. The method hasNext( ) in ListIterator returns true if there are more elements in the Vector while traversing in the forward direction and false otherwise. The method next( ... Read More

Find the maximum element of a Vector in Java

Arushi

Arushi

Updated on 30-Jun-2020 08:20:22

1K+ Views

The maximum element of a Vector can be obtained using the java.util.Collections.max() method. This method contains a single parameter i.e. the Vector whose maximum element is determined and it returns the maximum element from the Vector.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Collections; import java.util.Vector; public ... Read More

Perform Binary Search in Java using Collections.binarySearch

Arushi

Arushi

Updated on 30-Jun-2020 08:14:53

326 Views

Binary Search can be performed in Java using the method java.util.Collections.binarySearch(). This method requires two parameters i.e. the list in which binary search is to be performed and the element that is to be searched. It returns the index of the element if it is in the list and returns ... Read More

Print a Vector in a comma-delimited list, in index order and surrounded by square brackets ([]) in Java

Arushi

Arushi

Updated on 30-Jun-2020 08:04:49

521 Views

A Vector can be printed in a comma-delimited list, in index order and surrounded by square brackets ([]) by simply using System.out.println() along with the Vector object.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Vector; public class Demo {    public static void main(String args[]) {   ... Read More

How to reverse of integer array in android listview?

Arushi

Arushi

Updated on 26-Jun-2020 14:02:53

409 Views

This example demonstrate about How to reverse of integer array in android listview.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         ... Read More

How to print exception messages in android?

Arushi

Arushi

Updated on 26-Jun-2020 13:06:25

1K+ Views

This example demonstrate about How to print exception messages 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 ... Read More

How to insert integer array in android listview?

Arushi

Arushi

Updated on 26-Jun-2020 13:05:17

817 Views

This example demonstrate about How to insert integer array in android listview.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 ... Read More

How to check existence of an element in android listview?

Arushi

Arushi

Updated on 26-Jun-2020 12:50:35

552 Views

This example demonstrate about How to check existence of an element in android listview.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.                 In the ... Read More

Advertisements