String is immutable . So whatever data stored in String var remain for temporary whereas StringBuffer stores data permanently. so Stringbuffer is better
2009/8/11 Márcio Souza <[email protected]> > With String => You'll create 3 Strings. > With StringBuilder => You'll create 1 String. > > vlw! > You > > 2009/8/11 [email protected] <[email protected]> > > I always thought String was a final class, while StringBuffer wasn't. >> >> Cheers, >> >> -m >> >> On Tue, Aug 11, 2009 at 5:37 AM, hefaeche <[email protected]> wrote: >> >>> >>> What it's the difference? Which it's better? >>> >>> String str = new String( "Hola" ); >>> str = str.concat(" Mundo" ); >>> System.out.println( str ); >>> >>> vs >>> >>> StringBuffered str=new StringBuffered("Hola") >>> str.append( " Mundo" ); >>> System.out.println( str ); >>> >>> >>> (jdk 1.6) >>> >>> >>> >> >> >> -- >> I've never met anyone who liked George W. Bush. >> >> -Some guy from Denmark I met in Iceland >> >> >> >> > > > > -- AnAnD JAVA / J2EE Developer, . --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
