which toString() method can be used performance wise??
        Posted  
        
            by Mrityunjay
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Mrityunjay
        
        
        
        Published on 2010-06-16T05:51:24Z
        Indexed on 
            2010/06/16
            5:52 UTC
        
        
        Read the original article
        Hit count: 289
        
hi, I am working on one project for performance enhancement. I had one doubt, while we are during a process, we tend to trace the current state of the DTO and entity used. So, for this we have included toString() method in all POJOs for the same. I have now implemented toString() in three different ways which are following :-
public String toString() {
    return "POJO :" + this.class.getName() + " RollNo :" + this.rollNo + " Name :" + this.name;
}
public String toString() {
    StringBuffer buff = new StringBuffer("POJO :").append(this.class.getName()).append(" RollNo :").append(this.rollNo).append(" Name :").append(this.name);
    return buff.toString();
}
public String toString() {
        StringBuilder builder = new StringBuilder("POJO :").append(this.class.getName()).append(" RollNo :").append(this.rollNo).append(" Name :").append(this.name);
        return builder .toString();
    }
can anyone please help me to find out which one is best and should be used for enhancing performance.
© Stack Overflow or respective owner