Results 1 to 2 of 2

Thread: Using ArrayList

  1. #1
    blackpanther is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default Using ArrayList

    Hi,

    I have taken a set of values from a query and added those values into arrayList. Now i need those values in another class. how should i refer all the objects that i stored in the arrayList in another class?

  2. #2
    Lil_Aziz1's Avatar
    Lil_Aziz1 is offline Senior Member
    Join Date
    Dec 2009
    Location
    United States
    Posts
    343
    Rep Power
    5

    Default

    Um well you could just make a method that takes an ArrayList as a parameter and set that parameter to a class variable. Something like this:

    Java Code:
    public class AnotherClass {
    
         private ArrayList<Object> values;
    
         public AnotherClass() {
              ...
         }
    
         public void setList(ArrayList<Object> queries) {
             values = queries
         }
    }
    An alternative would be to pass the queries in the constructor. It's completely up to you.
    "Experience is what you get when you don't get what you want" (Dan Stanford)
    "Rise and rise again until lambs become lions" (Robin Hood)

Similar Threads

  1. Help with arraylist
    By alexisasoxfan in forum New To Java
    Replies: 12
    Last Post: 05-07-2010, 06:07 AM
  2. Arraylist
    By MaN-GreaSe in forum New To Java
    Replies: 2
    Last Post: 04-24-2010, 01:30 AM
  3. Replies: 2
    Last Post: 04-21-2008, 11:43 AM
  4. ArrayList
    By ramitmehra123 in forum New To Java
    Replies: 1
    Last Post: 02-07-2008, 12:47 AM
  5. ArrayList
    By kizilbas1 in forum New To Java
    Replies: 11
    Last Post: 12-05-2007, 07:30 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
  •