DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Volker Held Guest

    String concatenation - performance?

    Hi,

    i got a theoretical question....

    Letīs say i need to "construct" a long
    string out of may smaller ones either by
    writing them hard-coded or by calling
    method which return String objects, what
    approach is more effective - using the
    concatenation operator '+' or using a
    StringBuffer and the append() method (
    several times )?

    thx for any advice..

    Volker


  2. #2
    per Guest

    Re: String concatenation - performance?


    It is the same !
    The + operator makes a Stringbuffer internal in java so if you use + then
    java converts it to a stringbuffer - thats way it is the same.

    regards
    Per


    Volker Held <vheld@gwdg.de> wrote:
    >Hi,
    >
    >i got a theoretical question....
    >
    >Letīs say i need to "construct" a long
    >string out of may smaller ones either by
    >writing them hard-coded or by calling
    >method which return String objects, what
    >approach is more effective - using the
    >concatenation operator '+' or using a
    >StringBuffer and the append() method (
    >several times )?
    >
    >thx for any advice..
    >
    >Volker
    >



  3. #3
    Volker Held Guest

    Re: String concatenation - performance?

    Amazing!

    Thanks for the answer, per!!!!

    Volker

    per wrote:
    > It is the same !
    > The + operator makes a Stringbuffer internal in java so if you use + then
    > java converts it to a stringbuffer - thats way it is the same.
    >
    > regards
    > Per
    >
    >
    > Volker Held <vheld@gwdg.de> wrote:
    >
    >>Hi,
    >>
    >>i got a theoretical question....
    >>
    >>Letīs say i need to "construct" a long
    >>string out of may smaller ones either by
    >>writing them hard-coded or by calling
    >>method which return String objects, what
    >>approach is more effective - using the
    >>concatenation operator '+' or using a
    >>StringBuffer and the append() method (
    >>several times )?
    >>
    >>thx for any advice..
    >>
    >>Volker
    >>

    >
    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links