• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about VEctor

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI guyz ,
What is the size of a vector ?
we can access its elements by passing an integer as an argument so ,
is size of the vector equal to maximum integer value ?
dont hesitate to reply ,
just write whatever is in all of ur minds
regards
Khurram Fakhar
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pl. refer to the Java API specs for the Vector class.
Hope this answers most of the qstns. I hate to miss something
which you need to know.
Regds.
- satya
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vector defines two methods size() and capacity(). Size give number of you already stored and capacity() gives maximum number of objects can be stored.
 
Khurram Fakhar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ppl,
Well mr. Satya , i have already read the documentation but there is no material regarding my question.
My question was, what is the maximum size of a vector.
We ppl access elements of vectors by passing an integer value.
An integer has some specific limit to store some value.
So what if , elements in vector exceeds more than that limit of integer value ?
how can we access those elements which cant be accessed by passing integer argument ?
Correct me if i m wrong .

Regards
Khurram Fakhar
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So what if , elements in vector exceeds more than that limit of integer value ?
how can we access those elements which cant be accessed by passing integer argument

Forgive me, my imagination is limited
But, don't you think that an Exception of some kind will be
thrown when vector exceeds more than that limit of integer value.
I would guess thats what will happen.
Hope I got you right this time.
Regds.
- satya
 
Khurram Fakhar
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Mr. Satya for ur help

Regards
Khurram
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Vector is backed by an array. Since the dimension of an array is of type int, the capacity of a Vector (and thus its size too, since size <= capacity) is be at most Integer.MAX_VALUE.



If a Vector v already has the maximum size, then attempting to
addElement() will cause the following:

  • The new size-to-be will be considered to be Integer.MAX_VALUE + 1, i.e. Integer.MIN_VALUE
  • This being negative, hence smaller than the current capacity
    will result in a request to ensure capacity not to be made
  • An attempt to add the element will still be made (to position Integer.MIN_VALUE in the array). Integer.MIN_VALUE being negative, this will result in an ArrayIndexOutOfBoundsException.
    Hope this helps,
    Panagiotis.
    [This message has been edited by Panagiotis Varlagas (edited January 10, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic