Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CSE114 Fall 2015
Lab Exercise 1 of Week 4
Use Breakpoints and Debugger in Eclipse
Chen-Wei Wang
Problems
Create a new Java project CSE114 Week04 Lab1. Then create a new class ProcessArrays under CSE114 Week04 Lab1
with the proper main method header. In the main method, start with the following line of code that
initializes an array numbers of integers:
public class ProcessArrays {
public static void main(String[] args) {
int[] numbers = {1, 2, -3};
}
}
You may later alter the contents of the array numbers to test your software. For each of the following
tasks:
– Write a fragment of Java code that fulfills the task
– Try at least 3 different values of the contents of numbers and make sure that the outputs are
correct.
– Put breakpoints at the critical lines of your code and launch the Eclipse debugger to slowly walk
through the execution of your program.
– Pay special attention to the Variables and Expressions views in the Debug perspective. Add expres-
sions that matter for your program’s execution (e..g, stay conditions of loops) to the Expressions
view and observe how their values change.
1. Write a while loop that prints positive values only from numbers.
2. Write a for loop that prints the contents of numbers backwards.
3. Write a while loop that prints if numbers is sorted in a non-decreasing order.
4. Write two nested for loop that prints all possible pairs of values from numbers.
e.g., For the numbers array above, your program should print:
(1, 1)
(1, 2)
(1, -3)
(2, 1)
(2, 2)
(2, -3)
(-3, 1)
(-3, 2)
(-3, -3)
1