Results 1 to 7 of 7
Like Tree3Likes
  • 3 Post By KevinWorkman

Thread: Adding to an array

  1. #1
    HarleyRowland is offline Member
    Join Date
    Feb 2013
    Posts
    26
    Rep Power
    0

    Default Adding to an array

    How do i add to an empty Array whilst in a loop?

    I can't find any add function in the java api.

    All I have really tried is array1.add(..);

    Thanks.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: Adding to an array

    That's not how arrays work. Recommended reading: Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    (that's the first result for googling "java arrays" by the way, that's always a good place to start)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    HarleyRowland is offline Member
    Join Date
    Feb 2013
    Posts
    26
    Rep Power
    0

    Default Re: Adding to an array

    Okay thanks for your help!

  4. #4
    Zyrion is offline Member
    Join Date
    Feb 2013
    Posts
    4
    Rep Power
    0

    Default Re: Adding to an array

    If you need to add to arrays without a specified index you are able to use the vector method for a growing index.

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    7

    Default Re: Adding to an array

    What is a vector method?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    HarleyRowland is offline Member
    Join Date
    Feb 2013
    Posts
    26
    Rep Power
    0

    Default Re: Adding to an array

    Sorry I didn't see this when you posted. Thanks, i will look into the vector method!

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: Adding to an array

    Quote Originally Posted by HarleyRowland View Post
    Sorry I didn't see this when you posted. Thanks, i will look into the vector method!
    Please don't. There is no vector method. There is a Vector class, but you should almost always use the ArrayList class over the Vector class.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Help adding array values.
    By Kirstielol in forum New To Java
    Replies: 4
    Last Post: 03-20-2012, 07:42 PM
  2. Replies: 1
    Last Post: 04-05-2011, 09:58 PM
  3. Adding elements before and after array
    By liQuorice in forum New To Java
    Replies: 4
    Last Post: 03-04-2011, 01:52 AM
  4. Array always adding to 0???
    By Javawizard in forum New To Java
    Replies: 6
    Last Post: 11-14-2010, 12:02 AM
  5. adding to an array
    By mayhewj7 in forum New To Java
    Replies: 14
    Last Post: 02-19-2009, 06:41 AM

Posting Permissions

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