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

    Default Creating int[] but size needes to vary

    I need to create an int[] array in which the size needs to vary, is there a class that suits my needs so that I don't need to write something myself?

    As a bit of background: The values for this array are coming out of a SQL ResultSet. I should only need a single int from each record (could change later though), but depending on the database queried, the array will differ in size.

    I suppose I could do the query, run a loop to ResultSet.next() through it, incrementing a value (lets say 'i' for interest sake) as I go and then use ResultSet.first() to return to the first row of the ResultSet and then start recording in the array of size 'i'. However this seems silly and inefficient as it means I need to run through the ResultSet twice. Does anyone know of a class that could create an array with no fixed size?

    EDIT: Apologies for the spelling in the title, it hurts my eyes too.
    Last edited by porchrat; 07-22-2009 at 04:44 PM.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    835
    Rep Power
    6

    Default

    Arrays are of fixed size.Inorder to create arrays with dynamic size go far
    java.util.Vector or java.util.ArrayList
    Ramya:cool:

Similar Threads

  1. ResultSet size
    By bugger in forum JDBC
    Replies: 18
    Last Post: 06-25-2011, 08:36 PM
  2. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  3. how to set an image size
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:27 PM
  4. how to set the value of BUFFER SIZE
    By oregon in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 03:16 AM
  5. Replies: 1
    Last Post: 05-20-2007, 08:52 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
  •