Results 1 to 6 of 6
  1. #1
    porchrat is offline Senior Member
    Join Date
    Mar 2009
    Posts
    105
    Rep Power
    0

    Default [SOLVED] Vectors

    Hi all

    It has been a while since my last post, moved onto HTML at university now so that is occupying most of my attention these days.

    However there is something I have been wondering about. I have been reading up on vectors, but I don't know if I have properly understood what they are all about.

    From what I understand, a vector is basically an expandable 2D array?

    What sort of situations would call for this and is there a limit to how large this vector can be or is it only dependent on the heap size?

  2. #2
    Mr.Beans's Avatar
    Mr.Beans is offline Senior Member
    Join Date
    Apr 2009
    Location
    Virginia Beach, Virginia
    Posts
    149
    Rep Power
    0

    Default

    a vector is basically an expandable 2D array
    A Vector is an expandable one dimensional array. However, you can have a Vector of Vectors making it like an expandable two dimensional array.

    What sort of situations would call for this
    When you are going to need an array of x amount of objects but do not know what x will be.

    is there a limit to how large this vector can be or is it only dependent on the heap size?
    It is dependent only on the amount of heap available.

    Mr.Beans

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    8

    Default

    I suggest using ArrayList instead. Vector has built-in synchronization, which adds a lot of overhead.

  4. #4
    porchrat is offline Senior Member
    Join Date
    Mar 2009
    Posts
    105
    Rep Power
    0

    Default

    thanks guys that has helped me out a lot :)

    are vectors generally used for objects only or can vectors be used, like arrays, for primitive types as well?

  5. #5
    Join Date
    Mar 2009
    Posts
    25
    Rep Power
    0

    Default

    Only for objects. So for primitives use there wrapper classes (Integer, Character etc)

  6. #6
    porchrat is offline Senior Member
    Join Date
    Mar 2009
    Posts
    105
    Rep Power
    0

    Default

    Quote Originally Posted by hawaiian robots View Post
    Only for objects. So for primitives use there wrapper classes (Integer, Character etc)
    OK, that makes sense, thank you :D

Similar Threads

  1. Vectors of Vectors or hash-somethings?
    By mindwarp in forum New To Java
    Replies: 3
    Last Post: 03-10-2008, 03:57 PM
  2. Help with Vectors and Strings...
    By kaban in forum New To Java
    Replies: 2
    Last Post: 12-09-2007, 10:04 AM
  3. Vectors vs ArrayList
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-28-2007, 11:29 AM
  4. Understanding Vectors
    By cbrown08 in forum New To Java
    Replies: 7
    Last Post: 11-05-2007, 07:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •