This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

variable declaration and removal

 
Gajan Raj
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have a jsp page and id something like this
<%
String str;
use str
%>
html code
<%
String str;
use str
%>
I understand that I can't declare the variable str twice. However is there a way of destoying str after the first use so that it can be declared again...
Regards,
Gajan
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Destroying objects is best left to the JVM. If all you want to do is assign a new value to str, just assign a new value to str (how's that for a recursive answer!):

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gajan,
Alternatively, you can put part of the code in its own scope. This is useful if you are including a jsp within another and do not have control over the names.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic