Results 1 to 4 of 4
  1. #1
    ravl10 is offline Member
    Join Date
    Jan 2010
    Posts
    1
    Rep Power
    0

    Default Max size for a passed parameter?

    Hello.

    I've recently started coding seriously in Java, and I'm developing a little application that gathers information from the user, stores it in a vector, and then stores that vector in a vector of vectors.

    This Vector<Vector> gets passed to a few methods and it occurred to me that this vector could get very large if the user keeps inputting data, which prompts my post.

    Is there a maximum size for a passed parameter? Will there be exceptions or errors if the vector gets too large?

    Thanks in advance.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,762
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by ravl10 View Post
    Hello.

    I've recently started coding seriously in Java, and I'm developing a little application that gathers information from the user, stores it in a vector, and then stores that vector in a vector of vectors.

    This Vector<Vector> gets passed to a few methods and it occurred to me that this vector could get very large if the user keeps inputting data, which prompts my post.

    Is there a maximum size for a passed parameter? Will there be exceptions or errors if the vector gets too large?

    Thanks in advance.
    If you pass a primitive value (e.g. an int or a double etc.) you actually pass a copy of the value which takes up as much as 8 bytes. If you pass an object you actuall pass a copy of the reference (pointer) to the object which takes typically 4 bytes. As long as there are free bytes in the heap and you can store the object it can be passed as a parameter as long as there are at least 4 bytes available on the stack.

    kind regards,

    Jos

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default

    If the Vector (and you really ought to be using some form of List) gets really really really big you would eventually hit an OutOfMemory, but that has nothing to do with parameters.

  4. #4
    senorbum is offline Member
    Join Date
    Aug 2009
    Posts
    76
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    If the Vector (and you really ought to be using some form of List) gets really really really big you would eventually hit an OutOfMemory, but that has nothing to do with parameters.
    Yeah. His users almost will never, ever get this though. Unless he has billions of entries in the vector.

Similar Threads

  1. entities are passed by value or passed by reference
    By syntrax in forum New To Java
    Replies: 1
    Last Post: 12-17-2009, 08:13 AM
  2. java certification passed
    By natasha in forum Java Certification
    Replies: 0
    Last Post: 12-05-2009, 09:24 AM
  3. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 05:37 PM
  4. Cannot get passed these syntax errors
    By MrKP in forum New To Java
    Replies: 1
    Last Post: 05-12-2008, 08:05 AM

Tags for this Thread

Posting Permissions

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