S
Sreenivas
Friends,
What's use of capacity() method in StringBuffer Object
or
Why do we need it?
What's use of capacity() method in StringBuffer Object
or
Why do we need it?
What's ..
..use of capacity() method in StringBuffer Object
or
Why do we need it?
"Every string buffer has a capacity. As
long as the length of the character sequence
contained in the string buffer does not
exceed the capacity, it is not necessary
to allocate a new internal buffer array.
If the internal buffer overflows, it is
automatically made larger."
Friends,
What's use of capacity() method in StringBuffer Object
or
Why do we need it?
> ...
Wayne said:is that any reason not to add "getCapacity and setCapacity and
[...]Many of the methods in Java that violate naming standards
Stefan said:Wayne said:is that any reason not to add "getCapacity and setCapacity and
[...]Many of the methods in Java that violate naming standards
If you intent to say that »capacity« violates a naming standard,
could you give a reference to the naming standard for Java that
is violated by this?
Wayne said:The javabean (JavaBean?) standard of course.
While nearly all of Java adheres to this
standard there is the occasional oddball method name that
students must memorize as exceptions to the naming rules.
if( buffer.getSize() > 0 ) ~ ?
Wayne said:<off-topic peeve>
I have always wondered why Sun never fixed the broken names of
these methods. I understand about backward compatibility, but
is that any reason not to add "getCapacity and setCapacity and
then mark "capacity" and 'ensureCapcity" as deprecated (or not?)
Many of the methods in Java that violate naming standards could
be fixed without creating any problems, making the language
easier to learn. (Remember when Color constants were in lower
case? Now they're also in uppercase, as the naming standard
requires and nothing was broken by the addition.) Another
method that needs fixing is System.arraycopy, which should
be System.arrayCopy. (Maybe we should start a list and then
create a JSR to fix 'em all.
</off-topic peeve>
Eric said:Not speaking for Sun and in any case not privy to the debates
among the people who dreamed up the names, I can't see that adding
a get... prefix to half the methods in Creation does a whole lot
of good. (Well, it provides some informal capacity testing for
browsers when they load the G or S Javadoc index frames ;-)
Really, now: Is System.getCurrentTimeMillis() an improvement
on an already bletcherous name? Would renaming Number's methods
to getIntValue() and getDoubleValue() and so on make life easier
for anyone? Would Iterator be better if its methods were getNext()
and isAbleToGetNext()? Beauty is in the eye of the beholder, but
my eye at least finds no beauty in such names.
"A foolish consistency is the hobgoblin of little minds,
Adored by little statesmen and philosophers and divines."
-- Ralph Waldo Emerson
Stefan said:Wayne said:is that any reason not to add "getCapacity and setCapacity and
[...]Many of the methods in Java that violate naming standards
If you intent to say that »capacity« violates a naming standard,
could you give a reference to the naming standard for Java that
is violated by this?
Wayne said:<off-topic peeve>
I have always wondered why Sun never fixed the broken names of
these methods. I understand about backward compatibility, but
is that any reason not to add "getCapacity and setCapacity and
then mark "capacity" and 'ensureCapcity" as deprecated (or not?)
Joshua Cranmer said:The Sun Java coding standards specify that a method should be
named as a verb. "capacity" is not a verb, where as
{get,set}Capacity is (verb phrase, actually, but that's beside
the point).
Joshua Cranmer said:The Sun Java coding standards specify that a method should be
named as a verb. "capacity" is not a verb, where as
{get,set}Capacity is (verb phrase, actually, but that's beside
the point).
getCapacity and setCapacity a
Roedy said:Getters and setters are ugly. They should have been fixed long ago
borrowing from Delphi or Eiffel.
I have a proposal to fix the problem in the Bali language - reformed
Java. See http://mindprod.com/bali.html#PROPERTIES
Instead of writing:
x.setHeight( x.getHeight() + 1 );
you would write:
x.height++;
Getters and setters look syntatically to the outside world just like
public variables. Whether they are implemented as getter/setter or
public variables is an internal matter for the class. Of course they
generate slightly different byte code.
Getters and setters look syntatically to the outside world just like
public variables. Whether they are implemented as getter/setter or
public variables is an internal matter for the class. Of course they
generate slightly different byte code.
Which can be very confusing if the method does something besides
the standard.
Wayne said:have the last word, but I want to point out that only
methods which return/change the value of a property of an
object are supposed to follow this naming scheme, not all
non-void methods (as I think some people think I think,
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.