Using Printpoint (Intermediate)

Many IDEs use a tool called Printpoint to output the value of a variable to the console. It is the same as putting a print statement in the code. Unfortunately, Eclipse does not support Printpoint as a separate breakpoint type, but we will use a conditional breakpoint, which will give us the same result.

Getting ready

Please unset Watchpoint and make sure that the debugger is terminated. We will also need to comment out line 113, otherwise we won't be able to see Printpoint. So your line 113 should look like the following:

System.out.println("-=Employee Andrew=-"+andrew.toString());

How to do it...

  1. When line 113 is commented out, go to line 47 (number = _number), set a breakpoint, right-click on it, and go to Breakpoint Properties….
  2. Check the condition option.
  3. Focus on the textbox and type the following lines of code:
    System.out.println("employee number is "+number+ " but soon will be " + _number);
    return false;

    In these two lines we are doing two things. We are printing the value of number and _number, and also asking the application to not stop on the breakpoint by returning false.

  4. Click on Ok and run the debugger.

After running the debugger you should see the following output:

How to do it...

With Printpoints, you don't need to put your print statements in the code, which saves you time on looking for the print statements and removing them after you are done with debugging.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.12.34