Posts

Showing posts from January, 2018
Difference between recursion and iteration In recursive  approach the function calls itself until the condition is met. And it is slower than  iteration , which means it uses more memory than . R ecursion  is like a selection structure, and which makes code smaller and clean. And a function partially defined by itself. In  Java , C, and Python,  recursion  is fairly expensive compared to  iteration  (in general) because it requires the allocation of a new stack frame. I know that in some Scheme implementations,  recursion  will generally be  faster than  looping. In short, the answer depends on the code and the implementation In iterative approach  function is one that loops to repeat some part of the code . Using a simple for loop to display the numbers from one to ten is an  iterative  process. Program using iteration: class Factorial {       public static void main(S...
How to overload main() method. public class MultipleMainMethod  { public static void main (String args[])           { MultipleMainMethod m=new MultipleMainMethod();                System.out.println("Hello main method"); m.main(1);           }       public static void main(int arg)          { System.out.println("Hello Overloaded main method");          } }
Syntax to call main() method inside the main(). class MainDemo { public static void main(String args[]) { System.out.println("Hello World..."); main(new String[] {"John", "Pollard", "Bravo" }); } }