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

Not understanding why/how this gets the column/row of an array?  RSS feed

 
Mike Lonsky
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Can someone please explain to me how int col = o.get(0).length(); gets me the actual column? And how o.size() gets me the actual row size? I'm a bit confused. Thanks.

Edit: Btw everyone on this forum is great. Thank you for helping us.
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have an array there. You have a List of Strings. If you write get(0).length(), you find how many chars there are in the first String in the List. If the List is empty you will get an Exception. The size() method tells you how many elements there are in the List.

Please go back to whoever told you that sort of thing and ask exactly what they meant.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!