which class to use when concatenating
strings in a loop.

Answer Posted / narasimha

we any use the both classes String and StringBuffer.
but if we use StringBuffer it would be advatagebecase we
are going to create only one Object.if we use the String
class it is going to create the one for each itration.now
it up to you which one to use

Is This Answer Correct ?    4 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to handle exceptions in ejb?

1882


What is the difference between superclass and subclass?

555


What is io stream in java?

525


What is polymorphism and what are the types of it?

513


What is the meaning of find and replace?

529






Why java is secure? Explain.

604


What is a parameter in java?

550


What is anonymous inner class?

615


when to use ArrayList and when to use HashMap in webApplication.

3896


what is comparable and comparator interface?

582


What is the difference between the final method and abstract method?

544


what is the major difference between linkedlist and arraylist in java?

560


How do you clear a method in java?

544


In the below example, how many string objects are created?

562


If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

599