Java Reference
In-Depth Information
Setting breakpoints: You can also set a breakpoint at a specific statement. Your
program pauses when it reaches a breakpoint. You can set as many breakpoints as
you want. Breakpoints are particularly useful when you know where your program-
ming error starts. You can set a breakpoint at that statement and have the program
execute until it reaches the breakpoint.
Displaying variables: The debugger lets you select several variables and display
their values. As you trace through a program, the content of a variable is continuously
updated.
Displaying call stacks: The debugger lets you trace all of the method calls. This
feature is helpful when you need to see a large picture of the program-execution flow.
Modifying variables: Some debuggers enable you to modify the value of a vari-
able when debugging. This is convenient when you want to test a program with dif-
ferent samples but do not want to leave the debugger.
Tip
If you use an IDE such as Eclipse or NetBeans, please refer to Learning Java Effectively
with Eclipse/NetBeans in Supplements II.C and II.E on the Companion Website. The
supplement shows you how to use a debugger to trace programs and how debugging
can help in learning Java effectively.
debugging in IDE
K EY T ERMS
Boolean expression
82
flowchart 84
format specifier 113
operator associativity
boolean data type
82
Boolean value 82
conditional operator 104
dangling else ambiguity
116
operator precedence
116
94
selection statement
82
debugging 119
fall-through behavior
short-circuit operator
104
109
C HAPTER S UMMARY
1.
A boolean type variable can store a true or false value.
2. The relational operators ( < , <= , == , != , > , >= ) work with numbers and characters, and
yield a Boolean value.
3. The Boolean operators && , || , ! , and ^ operate with Boolean values and variables.
4. When evaluating p1 && p2 , Java first evaluates p1 and then evaluates p2 if p1 is
true ; if p1 is false , it does not evaluate p2 . When evaluating p1 || p2 , Java first
evaluates p1 and then evaluates p2 if p1 is false ; if p1 is true , it does not evaluate
p2 . Therefore, && is referred to as the conditional or short-circuit AND operator , and
|| is referred to as the conditional or short-circuit OR operator .
5. Selection statements are used for programming with alternative courses of actions.
There are several types of selection statements: if statements, two-way if-else
statements, nested if statements, multi-way if-else statements, switch state-
ments, and conditional expressions.
 
 
Search WWH ::




Custom Search