What does the method elementAt(int index) do in java?

Vikyath Ram
Published on 05-Jan-2018 10:19:10
The elementAt(int index) method is used to get the component at the specified index/location of the vector.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {       Vector<Integer> vec = new Vector<Integer>(4);       vec.add(4);       vec.add(3);       vec.add(2); ... Read More

What does the method ensureCapacity(int, minCapacity) do in java?

Govinda Sai
Published on 05-Jan-2018 10:42:09
The ensureCapacity(int minCapacity) method of the class java.util.ArrayList increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.Exampleimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String args[]) {       ArrayList<Integer> ... Read More

What does the method firstElement() do in java?

Paul Richard
Published on 05-Jan-2018 10:42:56
The firstElement() method is used to return the first component (the item at index 0) of this vector.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {       Vector<Integer> vec = new Vector<Integer>(4);       vec.add(4);       vec.add(3);       vec.add(2); ... Read More

What does the method lastElement() do in java?

Arushi
Published on 05-Jan-2018 10:46:07
The lastElement() method is used to return the last component of the vector.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {       Vector<Integer> vec = new Vector<Integer>(4);       vec.add(4);       vec.add(3);       vec.add(2);       vec.add(1);   ... Read More

What does the method listIterator(n) do in java?

Ankitha Reddy
Published on 05-Jan-2018 10:49:58
The listIterator(int index) method of the java.util.LinkedList class returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. Example import java.util.*; public class LinkedListDemo { public static void main(String[] args) { ... Read More

What does the method removeElementAt(int index) do in java?

George John
Published on 05-Jan-2018 10:53:36
The removeElementAt(int index) method is used to delete the component at the specified index. Each component in this vector with an index greater or equal to the specified index is shifted downward to have an index one smaller than the value it had previously and the size of this vector ... Read More

What does the method removeAllElements() do in java?

Rishi Raj
Published on 05-Jan-2018 11:01:39
The removeAllElements() method is used to remove all components from this vector and sets its size to zero. This method is identical in functionality to the clear method.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {       Vector<Integer> vec = new Vector<Integer>(4);   ... Read More

What does the method int capacity() do in java?

Vikyath Ram
Published on 05-Jan-2018 11:27:52
The capacity() method is used to return the current capacity of a vector. Capacity is the length of the array kept in the vector.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {       Vector<Integer> vec = new Vector<Integer>();       vec.add(14);     ... Read More

What does the method elements() do in java?

Paul Richard
Published on 05-Jan-2018 11:32:09
The elements() method is used to return an enumeration of the components of this vector. The returned Enumeration object will generate all items in this vector at the similar index location.Exampleimport java.util.Vector; public class VectorDemo {    public static void main(String[] args) {             Vector<Integer> ... Read More

What does the method push(Object item) do in java?

Arushi
Published on 05-Jan-2018 11:34:18
The push(Object item) method is used to Pushes an item onto the top of this stack.Exampleimport java.util.*; public class StackDemo {    public static void main(String args[]) {       Stack st = new Stack();       st.push("Java");       st.push("Source");       st.push("code");     ... Read More
Advertisements