Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

related to best practice

 
vasu chowdary
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not?
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just remember that it's zero-indexed, so use arrayList.get(0), etc.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean:
 
vasu chowdary
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vasu chowdary wrote:...webservice response object i get the ArrayList


Think why it is ArrayList and not an array?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic