Results 1 to 12 of 12
Thread: Array Concept
- 08-04-2011, 07:53 AM #1
Member
- Join Date
- May 2011
- Posts
- 97
- Rep Power
- 0
Array Concept
Hi all,
I Have a sql which will retrieve many rows,
all i want is how to store these each and every value what is retrieved at each loop in an array and later use each and value in array that is stored in different loop.
only thing i know is i have to use global array. in this concept array is off type String.
How to accomplish this?
Regards
SandeepLast edited by sandeep43; 08-04-2011 at 08:03 AM.
- 08-04-2011, 08:07 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
First think seriously about whether you really should make an array in the first place - after all the information already exists and is accessible in the database and you would be making a second copy. This may be useful, or it may not.only thing i know is i have to use global array.
Another thing to think about is whether you should use an array or some implementation of the List interface.
The array need not be global. Rather it should available to whatever method needs it. If both the method populating the array and the one accessing it are methods of the same class, then an instance variable is enough. If they are in different classes then the class that populates the array should provide a getter method.
- 08-04-2011, 08:11 AM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 08-04-2011, 08:32 AM #4
Member
- Join Date
- May 2011
- Posts
- 97
- Rep Power
- 0
Hi guys,
i am already using variable as pbrockway2 said, since i could not accomplish the task i wanted to use array concept and
@josAh: since i was closing the loop and later also i want to use same values i think my array should be global
So how can i do it guys, help me out?
Regards
Sandeep
- 08-04-2011, 08:41 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
I think you're misunderstanding some of the very basic concepts of the Java language. For one thing: reading a ResultSet and storing its values in an array is tricky: you have to know the number of values in advance; another thing: you can return those values from a method and the caller of the method has to know how to handle them; there is no need for anything 'global'.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 08-04-2011, 08:44 AM #6
Member
- Join Date
- May 2011
- Posts
- 97
- Rep Power
- 0
ok JOsAh
If thats the case how else can i handle the situation.
Regards
Sandeep
- 08-04-2011, 09:34 AM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 08-04-2011, 10:05 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Your requirements are a bit thin here.
What are you trying to achieve?
Where is this data going?
How much data is it?
- 08-04-2011, 10:13 AM #9
Member
- Join Date
- May 2011
- Posts
- 97
- Rep Power
- 0
ok JosAh i will give a shot for it
@tolls: i have a sql which will retrieve data and later this data has to be processed based on few condts and data size is unknown, we cant identify how much client has data in his database.
Sandeep
- 08-04-2011, 10:18 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
If there's a lot of data you might hit a memory problem trying to get it all into objects in a List.
Worht bearing in mind, though we are talking probably in the 10s of thousands of rows here at least.
- 08-04-2011, 11:33 AM #11
Member
- Join Date
- May 2011
- Posts
- 97
- Rep Power
- 0
Hi JosAH,
I used a variable and solved thnks for it.
@tolls i am able to handle 40,000 tables and more also as of now, in real time it will be less than that i am pretty dam sure about it.
Thnks guys.gif)
Regards
Sandeep
- 08-04-2011, 12:19 PM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Concept question
By erikjd21 in forum New To JavaReplies: 3Last Post: 04-10-2011, 02:14 PM -
Need help in thread concept
By umapathy_sekar in forum Advanced JavaReplies: 2Last Post: 11-11-2010, 06:25 AM -
enter key concept......
By silversurfer2in in forum AWT / SwingReplies: 5Last Post: 06-29-2010, 11:36 AM -
Thread concept
By javahelp00 in forum Threads and SynchronizationReplies: 2Last Post: 03-01-2009, 05:15 PM -
Interface concept
By r.srimathi in forum AWT / SwingReplies: 5Last Post: 01-28-2009, 04:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
.gif)

Bookmarks