String concatenation - performance?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: String concatenation - performance?

  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
    >>

    >
    >



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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center