Results 1 to 2 of 2
  1. #1
    JPH
    JPH is offline Member
    Join Date
    Sep 2011
    Posts
    1
    Rep Power
    0

    Default Is it Possible? Array elements Initialized in Loop, can it be viewed outside loop?

    I'm currently making a database of which you can add names (in an array), list them, edit them and delete them individually.
    I have used a loop to add the names to the array, however since the names are added to the array initializing inside the loop, I cannot view/print/use these names
    outside the loop.

    Is there any way of getting the various elements of the array to stay initialized within and outside the loop? or is there another way?
    Thanks for any replies! - I really need help - I'm a beginner.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,893
    Rep Power
    25

    Default Re: Is it Possible? Array elements Initialized in Loop, can it be viewed outside loop

    You should define the array variable outside of the method so that all methods can see it and its contents.
    You can assign it values any where in your code.

Similar Threads

  1. Array or for loop? or both?
    By kedecr in forum New To Java
    Replies: 4
    Last Post: 03-09-2011, 02:24 PM
  2. Replies: 3
    Last Post: 03-22-2010, 02:50 AM
  3. Replies: 0
    Last Post: 03-10-2010, 03:13 AM
  4. Variable not initialized after while loop
    By ejs7597 in forum New To Java
    Replies: 6
    Last Post: 02-28-2009, 06:00 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
  •