  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | JSP - A mailing list about Java Server Pages specification and reference | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | java code performance enhancement. | java code performance enhancement. 2004-09-24 - By Manish Malhotra
Back Hi All, Greet...
Please give me the list or some important points for the core java / ejb / jsp code performance enhancement.
And one basic question. Please see the following is the code snippet :
for (int i = 0; i < array.length; i++) { final String priority = (String) dataMap.get(SMSGConstants.SMSG_MESSAGE_PRIORITY); LogWriter.logDebugMessage("priority: " + priority); // Get the app name final String appName = (String) dataMap.get(SMSGConstants.SMSG_APPLICATION_NAME); LogWriter.logDebugMessage("appName: " + appName); LogWriter.logDebugMessage("CountryCOde: " + SMSGUtil.getIntValue(SMSGUtil.checkNull((String) dataMap.get (SMSGConstants.SMSG_COUNTRY_ISD_CODE)))); // Get the CC final int countryISDCode = SMSGUtil.getIntValue(SMSGUtil.checkNull((String) dataMap.get (SMSGConstants.SMSG_COUNTRY_ISD_CODE))); SPConfigKey spConfigKey = new SPConfigKey (countryISDCode, appName, priority); }
The point which I want to ask is as I declared the vars priority, appName, countryISDCode as final and in this loop. Now consider this case If I declare these vars outside this loop and obviously not final.
Performace and space vise which is better?
For the former type I give favour because I think that if I declare a var. in a block( in this case its a loop) then as soon as one iteration cmopletes all its vars are eligible for garbage collection. So, whatever the no. of var. or objects created in the loop all are eligible for GC. Is it correct?
And one more question If 'll not declare these vars as const then what's the difference. Is final object / var. takes lessa space or performance wise good. I dont have any idea about this.
Please do give the answers so that we ca start this interesting topic thread. Many Thanks.
regards, Manish
=========================================================================== 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".
|
|
 |