Strings 2005-10-27 - By SUBSCRIBE EJB-INTEREST anonymous
Back Hi, Can anyone say me which one of the below two options would be better in perfromance and which one would create more string objects? One has String ,str within while loop and one outside while loop. Thanks in advance,
Method : 1 public void printList(Vector v) { boolean flag = true; int i=0; while(flag){ String str = (String)v.get(i); System.out.println("The value :"+ str); if( i==5) flag = false; } }
Method : 2 public void printList(Vector v) { boolean flag = true; int i=0; String str = null; while(flag){ str = (String)v.get(i); System.out.println("The value :"+ str); if( i==5) flag = false; } }
=========================================================================== To unsubscribe, send email to listserv@(protected) and include in the body of the message "signoff J2EE-INTEREST". For general help, send email to listserv@(protected) and include in the body of the message "help".
|
|