This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

recursion Performance , Global Var  RSS feed

EM. Lashkar
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a mehod in a bean which returns a Set of "All" generations of subBusinesses ( Children) for a given business.
public Set getAllChildren3( String p_orgId){

Object l_busParentObj1 = null;

Map l_tempMap1 = new HashMap();
Set l_tempSet1 = new TreeSet();

// Getting all the 1st gen children
l_tempMap1= (Map)getChildBusMap( p_orgId) ;

if ( l_tempMap1.size()>0)
for (Iterator iTemp1=l_tempSet1.iterator(); iTemp1.hasNext(); )
if ( isThereChildBus(l_busParentObj1.toString()))
getAllChildren3( l_busParentObj1.toString());
return tempSet ;
// the method "getChildBusMap(" returns the immediate subBusiness( 1st generation Children) for a given Business
// where "tempSet" is a global reUsable Set Object, currently using only in this method.
The method works just fine , but I hate the fact that I had to use aglobal variable ! Its lot of work to keep track of global variables . Do you have any suggestion as to HOW I COULD USE A LOCAL VARIABLE in this recursion in place of "tempSet".
Any other design suggestion ?
Thx in dvance for reading this.
[ February 22, 2003: Message edited by: EM. Lashkar ]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!