aspose file tools*
The moose likes Associate Certification (SCJA,OCAJ 5/6) and the fly likes related to best practice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Associate Certification (SCJA,OCAJ 5/6)
Bookmark "related to best practice" Watch "related to best practice" New topic
Author

related to best practice

vasu chowdary
Ranch Hand

Joined: Mar 15, 2008
Posts: 90
Hi,

I have small doubt about ArrayList. As a part of the webservice response object i get the ArrayList where i can find exactly 3(not more ,not less and not null) objects in that list.Based on the 1st object value i have to populate another object and based on 2nd object i have to populate another object.So my question is instead of writing below logic


can i directly access the object based on the index like below
>
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1558
Why not?


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4489
    
    8

Just remember that it's zero-indexed, so use arrayList.get(0), etc.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

You mean:
vasu chowdary
Ranch Hand

Joined: Mar 15, 2008
Posts: 90
yes i mean
arrayList.get(0);
arrayList.get(1);
arrayList.get(2);

i heared that this not the best practice.is it correct?
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1558
vasu chowdary wrote:...webservice response object i get the ArrayList


Think why it is ArrayList and not an array?
 
Don't get me started about those stupid light bulbs.
 
subject: related to best practice