Alex Rivera | Logout

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

Asked 2010-02-04T21:38:07.630
9

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.

Edit
Report

2 Answers

10

Ideally, count would be the number of items, and size would be the amount of storage taken up (as in sizeof).

In practice, all three (including length, which is the most ambiguous) are muddled up in many widely-used libraries, so there's no point trying to impose a pattern on them at this stage.

answered 2010-02-04T22:01:42.807
3

I don't think so. It is more likely caused by the API being work on a large team and different people have different take on what the name should be, especially with words that synonym in certain context, such as size and length in this matter.

answered 2010-02-04T21:42:14.360

Your Answer