Debugging is different than running a program. Instead of running the entire program at once ,we debug it line by line. For that we have to follow two steps.
First set a break point anywhere in the program by double clicking that line and a dot will be added in the start.
Then we click the insect icon next to execute the program in debug prospective. It will open a debug prospective window in which on top right we will see breakpoints and variable tab and on left bottom we see console tab.The control will stop at our break point.
After that we have to click f6 to execute the program line by line and we keep checking variable tab to see variables getting assigned line by line and when we hit system.out..println commands we see console window for line by line output.
We can hit f8 to run entire program in one go as well.
The next thing is debugging a function. Note when we are debugging a program pressing f6 when control goes to a function it will not debug all the statements in the function line by line instead it will run them in one go.To debug a function either add a break point on the first line of the function.
Or what we can do is when the statement to call a function appears we press f5 and then statements in function will be executed one by one.