capacity of list

capacity of list

How to find the capacity of list. is there any method to find capacity of list like vector.capacity(); Thanks

View Answers

April 10, 2008 at 7:38 PM

Hi friend

import java.util.*;
import java.util.ArrayList;
import java.util.Vector;

public class ListCapacity{
public static void main(String args[]){
List list = new ArrayList();
Vector<Integer> vector = new Vector<Integer>(3, 2);
System.out.println("Initial size: " + vector.size());
list.add("amardeep");
list.add("Anjali");
System.out.println("Initial capacity: " + vector.capacity());
System.out.println("Total list:"+list);
vector.addElement(1);
vector.addElement(2);
System.out.println("First element: " + vector.firstElement());
System.out.println("Last element: " + vector.lastElement());
if (vector.contains(3))
System.out.println("Vector contains 3.");
}
}

-----------









Related Tutorials/Questions & Answers:
capacity of list - Java Interview Questions
capacity of list  How to find the capacity of list. is there any method to find capacity of list like vector.capacity(); Thanks   Hi... capacity: " + vector.capacity()); System.out.println("Total list:"
Retrieve the dynamic capacity of a list
Retrieve the dynamic capacity of a list        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
Advertisements
ModuleNotFoundError: No module named 'capacity'
ModuleNotFoundError: No module named 'capacity'  Hi, My Python... 'capacity' How to remove the ModuleNotFoundError: No module named 'capacity... to install padas library. You can install capacity python with following
ModuleNotFoundError: No module named 'capacity'
ModuleNotFoundError: No module named 'capacity'  Hi, My Python... 'capacity' How to remove the ModuleNotFoundError: No module named 'capacity... to install padas library. You can install capacity python with following
Get the capacity of a buffer
Get the capacity of a buffer In this tutorial we will see how to get size of buffer using capacity() method. Code: import java.nio.CharBuffer; public class CharBufferCapacityDemo 
How to get the capacity of ByteBuffer in java.
, we will discuss how to get the capacity of buffer. The ByteBuffer class...; In this example, we will compute the capacity of buffer. The capacity() method returns the capacity of buffer. The method allocate( int capacity) creates
Get the capacity of a double type buffer
Get the capacity of a double buffer In this tutorial we will see how to get size of a double buffer using capacity() method. Code: import java.nio.DoubleBuffer; public class 
Get the limit position and capacity of a double type buffer.
Get the limit position and capacity of a character buffer. In this tutorial you will see how to get the limit position and capacity of a character buffer...'s limit like wise capacity() and   position() methods return
Display total disk drive capacity
This method gets the total disk capacity in the bytes. Code... of this example depends upon number of drive you have and the total disk capacity
Get the limit position and capacity of a character buffer.
Get the limit position and capacity of a character buffer. In this tutorial you will see how to get the limit position and capacity of a character buffer...'s limit like wise capacity() and   position() methods return
please clarify regarding capacity method of my below string buffer class example
please clarify regarding capacity method of my below string buffer class...("length > is"+sb.length()); > System.out.println("capacity >...")); > System.out.println("capacity > is"+sb.capacity()); //Six position
List
List  i do have one list object, i want to compare this list from database table and if match found i want to update the list
List
List  getting values from a form and make a list of them and store them into database
List interface
List interface  What is the List interface
list boxs
list boxs  i have two list boxes first list box values from database and i want to assign selected options to the second list box using jsp is it possible to do this in jsp
linked list
linked list  program for single linked list
Linked list
Linked list  what is difference btw linked list in datastructure and linked list in java
List interface
List interface  Give me some of the real time examples that can be developed based on List and its implemented classes
Java list
Java list  What is the difference between a Choice and a List
List of mobiles
List of mobiles  which mobile phones support j2me
linked list
linked list  Hi i have a problem with linked list ! how and where i can use linked list? please give me some example.   Please visit...://www.roseindia.net/java/beginners/linked-list-demo.shtml
linked list
linked list   how to add student and mark and number from file in linked list and print them also how to make search function plz can help me sooon
linked list
linked list  hi i have basal problem what is the linked list
linked list
linked list   how to write a program using a linked list...); System.out.println("Add elements to LinkedList: "); LinkedList<String> list=new...); } Collections.reverse(list); System.out.println("List of names in reverse order
list and textbox
list and textbox  sir, i want to create a search, where when i type the letters, the words starting with that letters are to be searched and displayed. Also like a list i should navigate and select the appropriate word which
ModuleNotFoundError: No module named 'list-in-list'
ModuleNotFoundError: No module named 'list-in-list'  Hi, My Python... 'list-in-list' How to remove the ModuleNotFoundError: No module named 'list-in-list' error? Thanks   Hi, In your python
Linked List
in the following logical linked list represents Computer Number. 76(head) 98 54...? to ?66?. The segment should also display the new contents of the linked list. ii. Write a program segment to copy all ?Dell? computers to a new linked list
linked list
program to manage the registration details for the institute. 1. Use a linked list to manage the details of all registered students. a. Create your own linked list
Array List
Array List   Complete the class House and HouseApp below to display class House{ int lotNo; String type; //Bungalow, SemiDetached double price; public House ( int l, String t, double p) { ââ?¬Â¦ } public int theLotN() { Ã
DropDown list
DropDown list  how to get mysql database values into dropdown usign java servlet and ajax?   Here is a jsp code that displays the database values into dropdown list. 1)country.jsp: <%@page import="java.sql.*"%>
List In Java
List In Java In this section we will read about the List data structure in Java and how the List data structure can be implemented in Java. List data structure is implemented in Java using List interface. List interface allows
Shuffling the Element of a List or Array
the AbstractList class. It constructs an empty list. You can specify the capacity... Shuffling the Element of a List or Array   ... the list or array to prepare each and every element for the operation
pdf list
pdf list       In this program we are going to know how we can make a list in a pdf file irrespective... the document by document.open(). Create a numbered List with 30 point field
List in J2ME
List in J2ME       Exclusive List MIDlet Example This example illustrates how to create a Exclusive List. The Exclusive List is used to select only one list element at a time
List in J2ME
List in J2ME       J2ME Canvas List Example will explain you, how to create list of items. In this example we are going to create a simple list of text, that will show
Merge two list into a single list
list. Here you find mainly three function. The insertnode function makes node... and the mergelist funtion merge the two lists into a single list. Code: # include... ( struct node *p ) { printf("The data values in the list are\n"
ModuleNotFoundError: No module named 'list-within-list'
ModuleNotFoundError: No module named 'list-within-list'  Hi, My... named 'list-within-list' How to remove the ModuleNotFoundError: No module named 'list-within-list' error? Thanks   Hi, In your
Mysql List
Mysql List       Mysql List elaborate you an Query for listing databases,tables... The Tutorial illustrate an example from 'Mysql List'. To grasp this example, We
Mysql List
Mysql List       Mysql List elaborate you an Query for listing databases, tables, Procedure... The Tutorial illustrate an example from 'Mysql List'. To grasp this example, We
Java list of uninstantiated classes
Java list of uninstantiated classes  Java list of uninstantiated classes
array list example
array list example  Array list example   Hello Friend, Please visit the following links:ADS_TO_REPLACE_1 Array List Example1 Array List Example2 ThanksADS_TO_REPLACE_2
ultiple selections list in Struts
ultiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
drop down list in Struts
drop down list in Struts  How to create a drop down list in Struts
multiple selections list in Struts
multiple selections list in Struts  How to create a multiple selections list in Struts? and retrive seleted values
getting html list in a array
getting html list in a array  hi i want to get html unordered list in a array using jsp
getting html list in a array
getting html list in a array  hi i want to get html unordered list in a array using jsp
ModuleNotFoundError: No module named 'as_list'
ModuleNotFoundError: No module named 'as_list'  Hi, My Python... 'as_list' How to remove the ModuleNotFoundError: No module named 'as_list... to install padas library. You can install as_list python with following command
ModuleNotFoundError: No module named 'list_it'
ModuleNotFoundError: No module named 'list_it'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'list_it' How to remove the ModuleNotFoundError: No module named 'list
ModuleNotFoundError: No module named 'the_list'
ModuleNotFoundError: No module named 'the_list'  Hi, My Python... 'the_list' How to remove the ModuleNotFoundError: No module named 'the_list... to install padas library. You can install the_list python with following
What is the List interface?
What is the List interface?  Hi, What is the List interface? thanks,   The list interface is nothing but a subtype of tha java ordered... the order list of objects, can be access the elements of a list in a specific

Ads