Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Empty ArrayList

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but it is not even printing the string attached with it

new ArrayList(100) doesn't mean that the list has 100 items.
API wrote:public ArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.


It doesn't enter the loop. Why would it print the message ?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is an ArrayList, not an Array.
While you have defined the initial capacity, it is still empty until you put something in it.
The initial capacity is used for determining the supported size behind the scenes so that you can reduce the time spent resizing the data structure behind the scenes if you already know (or have a good idea of) the number of items going into the ArrayList
 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it ...Thanks Guys
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic