Debugging Programs in Eclipse


  1. Write a Java Program
    • Factorial Number
      • /** Compute the Factorial of n, where n=20.
          *    n! = 1*2*3*...*n
          */
        public class Factorial {
           public static void main(String[] args) {
              int n = 20;          // To compute factorial of n
              int factorial = 1;   // Init the product to 1
         
              int i = 1;
              while (i <= n) {
                 factorial = factorial * i;
                 i++;
              }
              System.out.println("The Factorial of " + n + " is " + factorial);
           }
        }
  2. Set an Initial Breakpoint
  3. Start Debugger
    • Right click anywhere on the source code (or from the "Run" menu) ⇒ "Debug As" ⇒ "Java Application" ⇒ choose "Yes" to switch into "Debug" perspective (A perspective is a particular arrangement of panels to suits a certain development task such as editing or debugging).
  4. Step-Over and Watch the Variables and Outputs & Breakpoint, Run-To-Line, Resume and Terminate

Comments

Popular posts from this blog

Import a GitHub project into Eclipse

Create Dynamic Web Project