Recursive Method in Java


Here is the example.

public static LinkedHashMap<String,String> process(LinkedHashMap<String,String> map) {
    // Do some process here.
   //Lets say you need to iterate this method until your map getting empty.
  //then this is the way to do that.
  if( map.isEmpty() )
      return null; // Here brake the loop. 
  else 
     return process(map); // Here still continue the loop
}

Cheers. 

Comments

Popular Posts