Is there a technical difference between the terms "length" and "size" (in programming, of course)?

Tom R picture Tom R · Feb 4, 2010 · Viewed 9.6k times · Source

Possible Duplicate:
count vs length vs size in a collection

In Java in particular, on Strings, you call string.length(), whereas in Lists you call list.size(). Is there a technical difference between the two terms, seeing as a String is really just a list of chars?

Any comments appreciated.

Answer

Joel Rondeau picture Joel Rondeau · Feb 4, 2010

In general, length() is used when something has a constant length, while size() is used on something with a variable length. Past that, I know of no good reason for using two nearly-synonymous terms.