第二章基本数据类型和基本操作规范.ppt
文本预览下载声明
* Class 名: ComputeArea. 常量: PI and MAX_VALUE * 适当的缩进和空白 缩进风格 每个内层的组件或语句应该比外层缩进两格. 空行 使用空行把代码分段,以使程序更容易阅读. * 块的对齐方式 次行风格和尾行风格 ? * 编程错误 语法错误 编译过程中出现的错误 运行错误 引起程序非正常中断的错误(错误的输入类型,0做除数等) 逻辑错误 没有按照期望的要求执行 * 语法错误 public class ShowSyntaxErrors { public static void main(String[] args) { i = 30; System.out.println(i + 4); } } * 运行时错误 public class ShowRuntimeErrors { public static void main(String[] args) { int i = 1 / 0; } } * 逻辑错误 public ShowLogicError() { public static void main(String[] args) { int number1=2; int number2=3; number2+=number1+number2; System.out.println(number2=+number2); } } * Debugging Logic errors are called bugs. The process of finding and correcting errors is called debugging. A common approach to debugging is to use a combination of methods to narrow down to the part of the program where the bug is located. You can hand-trace the program (i.e., catch errors by reading the program), or you can insert print statements in order to show the values of the variables or the execution flow of the program. This approach might work for a short, simple program. But for a large, complex program, the most effective approach for debugging is to use a debugger utility. * Debugger Debugger is a program that facilitates debugging. You can use a debugger to Execute a single statement at a time. Trace into or stepping over a method. Set breakpoints. Display variables. Display call stack. Modify variables. * Debugging in JBuilder The debugger utility is integrated in JBuilder. You can pinpoint bugs in your program with the help of the JBuilder debugger without leaving the IDE. The JBuilder debugger enables you to set breakpoints and execute programs line by line. As your program executes, you can watch the values stored in variables, observe which methods are being called, and know what events have occurred in the program. JBuilder Optional * Setting Breakpoints A breakpoint is a stop sign placed on
显示全部