Jai Janardhan has Published 89 Articles

Method Overloading based on the order of the arguments in Java

Jai Janardhan

Jai Janardhan

Updated on 30-Jun-2020 08:40:27

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. One way to make sure that the parameter list is different is to change the order of the arguments in the methods.A program that demonstrates ... Read More

Create Objects of a Class in Java

Jai Janardhan

Jai Janardhan

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

An object is created from a class using three steps i.e. declaration, instantiation, initialization. First the object is declared with an object type and object name, then the object is created using the new keyword and finally, the constructor is called to initialize the object.A program that demonstrates object creation ... Read More

Loop through the Vector elements using an Iterator in Java

Jai Janardhan

Jai Janardhan

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

An Iterator can be used to loop through the Vector elements. The method hasNext( ) returns true if there are more elements in the Vector and false otherwise. The method next( ) returns the next element in the Vector and throws the exception NoSuchElementException if there is no next element.A ... Read More

Find the minimum element of a Vector in Java

Jai Janardhan

Jai Janardhan

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

The minimum element of a Vector can be obtained using the java.util.Collections.min() method. This method contains a single parameter i.e. the Vector whose minimum element is determined and it returns the minimum 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

How a list can be sorted in Java

Jai Janardhan

Jai Janardhan

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

A list can be sorted in ascending order using the java.util.Collections.sort() method. This method requires a single parameter i.e. the list to be sorted and no value is returned. The ClassCastException is thrown by the Collections.sort() method if there are mutually incomparable elements in the list.A program that demonstrates this ... Read More

Append all elements of another Collection to a Vector in Java

Jai Janardhan

Jai Janardhan

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

The elements of a Collection can be appended at the end of the Vector using the method java.util.Vector.addAll(). This method takes a single parameter i.e. the Collection whose elements are added to the Vector and it returns true if the Vector is changed.A program that demonstrates this is given as ... Read More

Clear out all of the Vector elements in Java

Jai Janardhan

Jai Janardhan

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

A Vector can be cleared in Java using the method java.util.Vector.clear(). This method removes all the elements in the Vector. There are no parameters required by the Vector.clear() method and it returns no value.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Vector; public class Demo {   ... Read More

Sorting a Strings in Java

Jai Janardhan

Jai Janardhan

Updated on 27-Jun-2020 08:41:28

In order to sort a string in java we could use the arrays API and its inbuilt method sort which internally implementing sorting algorithm and would return a sorted string.First we will convert our string into a character array and then sort this array using sort method of Arrays class ... Read More

How to set the right margin of an element with JavaScript?

Jai Janardhan

Jai Janardhan

Updated on 23-Jun-2020 13:29:34

Use the marginRight property in JavaScript, to set the right margin. You can try to run the following code to set the right margin of an element with JavaScript −ExampleLive Demo                    #myID {             ... Read More

How to set the position of the list-item marker with JavaScript?

Jai Janardhan

Jai Janardhan

Updated on 23-Jun-2020 13:20:40

To set the position of the marker of the list-item, use the listStylePosition property. You can try to run the following code to set the position of the list-item marker with JavaScript −ExampleLive Demo                    One         ... Read More

1 2 3 4 5 ... 9 Next
Advertisements