|
Course Background
In this course, you will be working with Java coding to do exception handling,
code debugging, Java code development, UML (Unified Modeling Language) designing
of classes and Java programs, and creating graphical user interfaces using Java Swing.
You will use the open source Eclipse as the IDE (Interface Development Environment)
for you coding and program debugging, which is free for download and use.
Before installing Eclipse on your machine, you must have the Java SDK
(Software Development Kit) installed on your machine. Instructions on how to install
the SDK are located in Appendix B1 in the online maerial for SSD3. Once the SDK is
properly installed and is fully functional on the clint machine, then it is possible
to install Eclipse. Instructions on how to install Eclipse is located in Appendix C1
on the online SSD3 course. Once the SDK and Eclipse program have been successfully
installed, another separate program Eclipse UML must be installed in order to use UML diagramming.
The course starts with learning how to use Eclipse in Unit 1. You will learn how to debug Java applications
and do exception handling within Java. Use of Omondo UML plug-ins to Eclipse will also be used to model UML
diagrams in the course.
In Units 2 and 3, you will write simple Java programs that can be
incorporated in your web pages. In the process, you will learn and practice the
following: compilation, syntax rules, variables, rudimentary object-oriented
concepts (specifically classes, objects, and inheritance), data types, control
structures, loops, and so on.
Each of the three units has several modules.
Each module contains a homework exercise as well as both a multiple-choice quiz
and a practical quiz. The course also contains three in-class exams. You can
read about how to work through the quizzes, exercises, and exams in the course
Help pages.
You can use Eclipse to write and create your Java code. If you may not have access or have problems using Eclipse,
you may also try to use any text or program to create your HTML or Java code, but the basic editor you can use on
Microsoft Window machines is Notepad. Notepad is located by going to:
Start->Programs->Accessories->Notepad
**NOTE ON TAKING ONLINE ICARNEGIE EXAMS**
Unit 1,2,3 & Final Multiple Choice Exams
– Students cannot use any online or book material while taking the multiple choice tests.
Unit 1,2,3 & Final Practical Exams
– Students are allowed to use all of the online iCarnegie material,
including their submitted files, while taking the practical exam. Use of book material
Internet sites (except potential class websites posted by the instructor) cannot be used.
Eclipse Exercise Downloads for Supplemental Handout
You will be using Eclipse to compile (create) your Java programs. If there are problems in using Eclipse,
it is possible to also use DOS to compile Java file sif Java has been set up properly on the machine.
The following tables provide file data to download to do the work in the supplemental handout information:
Downloadable Project File Templates
| Chapters |
Project |
Description |
| 29 |
com.ibm.lab.usingjdt |
Code for exercises in Chapters
29 and 30 to illustrate use of Java Development Tools (JDT) |
| Exercise 2: Using the Java Development Tools
(JDT) |
| 29 |
com.ibm.lab.usingjdt.jre14
|
Code for exercises in Chapters
29 and 30 to illustrate use of Java Development Tools (JDT) |
| Exercise 2: Using the Java
Development Tools (JDT) |
| 29 |
com.ibm.lab.usingjdt.launchconfigurations
|
Code for exercises in Chapters
29 and 30 to illustrate use of Java Development Tools (JDT) |
| Exercise 2: Using the Java
Development Tools (JDT) |
Exercise Solutions
The following are solutions to the exercises.
Follow the links to the solution description
that contain more details.
Exercise Solutions
| Chapters |
Projectt/Chapter Title |
Description |
| 29 |
com.ibm.lab.soln.usingjdt
|
Solution to exercise in Chapters 29 to illustrate use of Java Development Tools (JDT)
|
| Exercise 2: Using the Java Development Tools
(JDT) |
| 29 |
com.ibm.lab.soln.usingjdt.helloworld |
Solution to exercise in Chapters 29 to illustrate use of Java Development Tools (JDT)
|
| Exercise 2: Using the Java Development Tools
(JDT) |
| 29 |
com.ibm.lab.soln.usingjdt.jre14 |
Solution to exercise in Chapters 29 to illustrate use of Java Development Tools (JDT)
|
| Exercise 2: Using the Java Development Tools
(JDT) |
| 29 |
com.ibm.lab.soln.usingjdt.launchconfigurations
|
Solution to exercise in Chapters 29 to illustrate use of Java Development Tools (JDT)
|
| Exercise 2: Using the Java Development Tools
(JDT) |
Unit 1 Useful Information and Links:
Unit 2 Useful Information and Links:
Programming Iterators using While loops in Java
A computer program is hardly
clever. The real advantage with a computer
is that it can perform calculations fast and
accurately. These advantages are only really
apparent when you program a computer to perform
the same task repetitively. Such a repeated task
is a "loop". While using an iterator, there are 2 forms it can take (the for-loop and the while-loop) with both having some associated java constructions.
Study this java program: Iterate1.java.
In the above file, there are two new features here: "iterators" and the "while loop".
An "Iterator object" i is a special kind of object that generates
a list of other objects. You can tell if there are more
objects in the list by looking at the "hasNext()" method of i.
If there are more elements, i.hasNext() will be "true", else it is
"false". As you can see from the program, the way to get
an Iterator object from a Vector object v is to apply the
iterator method: i = v.iterator(). Careful with the capital
letters. In java, names of "types" or "kinds" of objects
always start with a capital letter, and names of methods
and variables always start with a lower case letter.
------------------------------------------------------------------------------------------------
The normal java for loop without Iterator:
Vector things; // Java Collection type
for ( int i = 0 ; i < things.size() ; i++ ) { // Notice the normal for loop has 3 parts
// do something with things.get(i)
// get is a method of the Vector class
}
The java while loop with Iterator takes the form:
Vector things; // Java Collection type
Iterator i = things.iterator(); // declares a name for a Iterator Object
while (i.hasNext()) { // Notice the while loop has 1 part, the boolean conditional
// do something with i.next()
// next is a method of the iterator class
}
The java for loop with Iterator takes the form:
Vector things; // Java Collection type
for ( Iterator i = things.iterator() ; i.hasNext();) { // Notice the for loop has 2 parts
// do something with i.next()
// next is a method of the iterator class
}
------------------------------------------------------------------------------------------------
It is important that the Iterator classes hasNext() method returns a
boolean "true" or "false". Java will execute the code "do something...." repeatedly
provided the boolean test returned from the hasNext method comes out true. When the test comes out false, java skips to the next part of the program.
More precisely it:
- computes "hasNext()";
- if "hasNext()" is false it skips the loop and all the code in
"do something...";
- else it performs the "do something...." once and goes back to step 1.
Note that the code "do something......" will be completely ignored if the test
comes out false the first time. Also note that "hasNext()" is recalculated
just before each time through the loop body.
Warning: the only semicolons you need in a while statement
are in the "do something...." part (the loop body). You don't need
a semicolon after the final } (though it wouldn't hurt) and you
definitely don't want a semicolon after "while (hasNext())" - putting
a semicolon here would completely mess up your while loop, and
(worse) the java compiler wouldn't complain so you may not
even get an inkling of a problem. Be careful!
More java program involving iteration, and while loops
follow. Read them, try them out, and modify them
so that you understand what each line does.
- Iterate2.java. This has a while loop inside
another while loop.
- Iterate3.java. This introduces the "if"
statement.
- Iterate4.java. This is a slightly more
complicated example, and uses a static method.
- Iterate5.java. Slightly more
complicated again, it shows how you can use static methods
to help you understand and simplify "loops within loops".
Unit 3 Useful Information and Links:
If you have any questions, please feel free to e-mail Bob at:bscheele@bscheele.com
|