In this section you will learn
to get the capacity of a list i.e. retrieving the number of objects contained in
it. Here is an example that provides the
usage of the size() method in more detail.
Create a class "VecSize" with a Vector. Populate
it with the integer objects using add(object) method. Now
retrieve the total number of objects contained in it using the
size() method.
Here is the Code of the Example :
VecSize.java:
import java.util.*;
|
Here is the Output of the Example :
| C:\roseindia>javac VecSize.java
C:\roseindia>java VecSize |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Retrieve the dynamic capacity of a list
Post your Comment