Arushi has Published 184 Articles

Use overloaded methods to print array of different types in Java

Arushi

Arushi

Updated on 30-Jun-2020 08:38:41

In method overloading, the class can have multiple methods with the same name but the parameter list of the methods should not be the same.Overloaded methods can be used to print an array of different types in Java by making sure that the parameter list of the methods contains different ... Read More

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

Arushi

Arushi

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

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

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

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

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

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

Class with a constructor to initialize instance variables in Java

Arushi

Arushi

Updated on 30-Jun-2020 08:06:52

A class contains a constructor to initialize instance variables in Java. This constructor is called when the class object is created.A program that demonstrates this is given as follows −Example Live Democlass Student {    private int rno;    private String name;    public Student(int r, String n) {     ... 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

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

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

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

1 2 3 4 5 ... 19 Next
Advertisements